Download the PHP package namelesscoder/numerolog-phpunit without Composer

On this page you can find all versions of the php package namelesscoder/numerolog-phpunit. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package numerolog-phpunit

Numerolog: PHPUnit extension

Build Status Coverage Status

Provides a new type of test case base class which contains additional assertion methods based on the statistical information gathered and analysed by Numerolog.

Numerolog uses a remote server (a free, public one is used by default) to store values - this package integrates that with PHPUnit to create assertions which for example cause a failure if a value increases; and learns over time when it decreases so that the expected maximum value goes lower and lower.

Intended purposes

  1. Assertions based on statistical information rather than hardcoded values.
  2. An automatically "learning" way to measure performance of code during iterative development where each assertion "raises the bar" for the next.
  3. Doing so in a distributed way that fits with CI platforms like Travis.

The assertions can be used for execution time tracking but should be used very carefully for this: consistency is vital which means distributed tests may not be a wise choice when asserting time-based statistics.

The assertions are naturally ideal for tracking values such as:

A successful assertion performed on a system that has a Numerolog token will result in a new value being recorded. In other words: authenticated users and systems both run tests and record statistics.

Statistics generated by numerolog-phpunit can then be retrieved using standard Numerolog commands and integrations (among other things for generating charts).

Background knowledge

If you start on the public server and later need to move, the author will happily give you access to your data storage files for transfer - assuming they contain significant amounts of data! If your storages are very light please just recreate them on your own end point.

Usage

Require via composer using composer require namelesscoder/numerolog-phpunit, then use \NamelessCoder\NumerologPhpunit\StatisticsTestCase as parent class for your test cases (which otherwise follow all phpunit rules). Alternatively, you can use the \NamelessCoder\NumerologPhpunit\StatisticsTestCaseTrait as trait in your class; for those cases when that fits better with your unit tests' structure. Both methods will provide the same functions for your test case.

There are five types of assertions to compare with various statistics:

Where $counterName is a lowerCamelCase name of a single counter; where $value is the new value you with to compare - and where $count is the number of values to pull from history and use as data set in comparison.

And where the ****** can be one of the following four statistics parameters:

Which means a total of 20 (5 x 4) simple statistical assertion methods.

Your test methods can also perform the following more advanced assertions:

Example

When put together, a complete statistical unit test function can look like:

The Monitor class is not included and is hypothetical. Any measurement method can be used. In this test, we have our $subject do something that's known to cause a lot of memory usage - and then assert that, with the code base that we currently are on, the usage does not deviate more than two standard deviations from the recorded average. And we assert that the usage is either less than or equal to the average recorded value.

Assuming the Numerolog token exists in the project doing the assertions, each successful assertion adds to the statistical history. In this case, we are continually testing that our memory usage does not increase; as well as testing that it doesn't suddenly decrease drastically. Which means that as you improve the code that gets tested, Numerolog ensures that your tests also "learn" what to expect without you having to continually modify test cases to change the expectations like you normally would with a unit test.

Pitfalls

If the code you are testing depends on a framework or has other dependencies, make sure you sufficiently mock all of those dependencies in PHPUnit or the numbers may be inadvertedly skewed by changes occurring in the framework or dependency. For example, in the hypothetical case that you have a Symfony component as dependency and that component suddenly decreases in performance (whatever the reason may be) then your tests may fail if you did not sufficiently mock that dependency. Obviously the PHPUnit code itself also counts unless you are careful, e.g. don't include calls to assertion methods or mock generation in the code window you profile.

Essentially: use proper unit test design to avoid unexpected problems with the variables you profile and track.


All versions of numerolog-phpunit with dependencies

PHP Build Version
Package Version
Requires phpunit/phpunit Version ^4.8
namelesscoder/numerolog Version ^1.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package namelesscoder/numerolog-phpunit contains the following files

Loading the files please wait ....