Download the PHP package vtsmedia/paratest without Composer
On this page you can find all versions of the php package vtsmedia/paratest. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download vtsmedia/paratest
More information about vtsmedia/paratest
Files in vtsmedia/paratest
Package paratest
Short Description Parallel testing for PHP
License MIT
Homepage https://github.com/elliotmoso/paratest
Informations about the package paratest
ParaTest
The objective of ParaTest is to support parallel testing in PHPUnit. Provided you have well-written PHPUnit tests, you can drop paratest
in your project and
start using it with no additional bootstrap or configurations!
Benefits
Why use paratest
over the alternative parallel test runners out there?
- Code Coverage report combining. Run your tests in N parallel processes and all the code coverage output will be combined into one report.
- Zero configuration. After composer install, run with
vendor/bin/paratest -p4 path/to/tests
. That's it! - Flexible. Isolate test files in separate processes or take advantage of WrapperRunner for even faster runs.
Installation
Composer
To install with composer add the following to your composer.json
file:
Then run php composer.phar install
Usage
After installation, the binary can be found at vendor/bin/paratest
. Usage is as follows:
Optimizing Speed
To get the most out of paratest, you have to adjust the parameters carefully.
-
Adjust the number of processes with
-p
To allow full usage of your cpu cores, you should have at least one process per core. More processes allow better resource usage but keep in mind that each process has it's own costs for spawning.
-
Choose between per-testcase- and per-testmethod-parallelization with
-f
Given you have few testcases (classes) with many long running methods, you should use the
-f
option to enable thefunctional mode
and allow different methods of the same class to be executed in parallel. Keep in mind that the default is per-testcase-parallelization to address inter-testmethod dependencies. Note that in most projects, using-f
is slower since each test method will need to be bootstrapped separately. -
Use the WrapperRunner if possible
The default Runner for PHPUnit spawns a new process for each testcase (or method in functional mode). This provides the highest compatibility but comes with the cost of many spawned processes and a bootstrapping for each process. Especially when you have a slow bootstrapping in your tests (like a database setup) you should try the WrapperRunner with
--runner WrapperRunner
. It spawns one "worker"-process for each parallel process (-p
), executes the bootstrapping once and reuses these processes for each test executed. That way the overhead of process spawning and bootstrapping is reduced to the minimum. -
Tune batch max size
--max-batch-size
Batch size will affect on max amount of atomic tests which will be used for single test method. One atomic test will be either one test method from test class if no data provider available for method or will be only one item from dataset for method. Increase this value to reduce per-process overhead and in most cases it will also reduce parallel efficiency. Decrease this value to increase per-process overhead and in most cases it will also increase parallel efficiency. If amount of all tests less then max batch size then everything will be processed in one process thread so paratest is completely useless in that case. The best way to find the most effective batch size is to test with different batch size values and select best. Max batch size = 0 means that grouping in batches will not be used and one batch will equal to all method tests (one or all from data provider). Max batch size = 1 means that each batch will contain only one test from data provider or one method if data provider is not used. Bigger max batch size can significantly increase phpunit command line length so process can failed. Decrease max batch size to reduce command line length. Windows has limit around 32k, Linux - 2048k, Mac OS X - 256k.
Examples
Examples assume your tests are located under ./test/unit
.
Windows
Windows users be sure to use the appropriate batch files.
An example being:
vendor\bin\paratest.bat --phpunit vendor\bin\phpunit.bat ...
ParaTest assumes PSR-0 for loading tests.
For convenience paratest windows version use 79 columns mode to prevent blank lines in standard 80x25 windows console.
PHPUnit Xml Config Support
When running PHPUnit tests, ParaTest will automatically pass the phpunit.xml or phpunit.xml.dist to the phpunit runner via the --configuration switch. ParaTest also allows the configuration path to be specified manually.
ParaTest will rely on the testsuites
node of phpunit's xml configuration to handle loading of suites.
The following phpunit config file is used for ParaTest's test cases.
Test token
The TEST_TOKEN
environment variable is guaranteed to have a value that is different
from every other currently running test. This is useful to e.g. use a different database
for each test:
For Contributors: Testing paratest itself
ParaTest's test suite depends on PHPUnit being installed via composer. Make sure you run composer install
after cloning.
Note that The display_errors
php.ini directive must be set to stderr
to run
the test suite.
To run unit tests:
vendor/bin/phpunit test/unit
To run functional tests:
vendor/bin/phpunit test/functional
You can run all tests at once by running phpunit from the project directory.
vendor/bin/phpunit
ParaTest can run its own test suite by running it from the bin
directory.
bin/paratest
For an example of ParaTest out in the wild check out the example.
All versions of paratest with dependencies
phpunit/phpunit Version ~5.0
phpunit/php-timer Version >=1.0.4
symfony/console Version ~2.3|~3.0
symfony/process Version ~2.3|~3.0
brianium/habitat Version 1.0.0
ext-reflection Version *
ext-simplexml Version *
ext-pcre Version *
composer/semver Version ~1.2