Skip to content
This repository

Parallel testing for PHPUnit

Merge branch 'stop-on-failure' of https://github.com/mpartel/paratest

…into mpartel-stop-on-failure

Conflicts:
	README.md
	functional/PHPUnitTest.php
	it/ParaTest/Runners/PHPUnit/RunnerIntegrationTest.php
	src/ParaTest/Console/Testers/PHPUnit.php
	src/ParaTest/Runners/PHPUnit/Options.php
	test/ParaTest/Console/Commands/ParaTestCommandTest.php
	test/ParaTest/Console/Testers/PHPUnitTest.php
	test/ParaTest/Runners/PHPUnit/SuiteLoaderTest.php
	test/fixtures/output/usage.txt
latest commit da81030376
Julian Seeger julianseeger authored
Octocat-spinner-32 bin Environment variables are not prefixed anymore to commands, but only … June 30, 2013
Octocat-spinner-32 functional Merge branch 'stop-on-failure' of https://github.com/mpartel/paratest April 12, 2014
Octocat-spinner-32 it Merge branch 'stop-on-failure' of https://github.com/mpartel/paratest April 12, 2014
Octocat-spinner-32 src Merge branch 'stop-on-failure' of https://github.com/mpartel/paratest April 12, 2014
Octocat-spinner-32 test Merge branch 'stop-on-failure' of https://github.com/mpartel/paratest April 12, 2014
Octocat-spinner-32 .gitignore Merging master and environment_variable March 02, 2013
Octocat-spinner-32 .travis.yml Add php 5.6 to the travis build matrix. April 02, 2014
Octocat-spinner-32 Guardfile initial commit October 12, 2012
Octocat-spinner-32 LICENSE include LICENSE file and update LICENSE to MIT June 15, 2013
Octocat-spinner-32 README.md Merge branch 'stop-on-failure' of https://github.com/mpartel/paratest April 12, 2014
Octocat-spinner-32 TODO.txt The standard behavior in case of Fatal Error is to interrupt the whol… March 03, 2013
Octocat-spinner-32 composer.json Allow version 2.4 stable of Symfony Process and Console components. December 04, 2013
Octocat-spinner-32 paratest-usage.png added coverage-options to README and paratest-usage November 10, 2013
Octocat-spinner-32 phpunit.xml.dist fix phpunit xml and fix naming collisions in tests December 21, 2012
README.md

ParaTest

Build Status

The objective of ParaTest is to support parallel testing in a variety of PHP testing tools. Currently only PHPUnit is supported.

Installation

Composer

To install with composer add the following to your composer.json file:

"require": {
    "brianium/paratest": "dev-master"
}

Then run php composer.phar install The display_errors php.ini directive must be set to stderr to run the test suite.

Usage

After installation, the binary can be found at vendor/bin/paratest. Usage is as follows:

paratest [-p|--processes="..."] [-f|--functional] [--no-test-tokens] [-h|--help]
 [--coverage-clover="..."] [--coverage-html="..."] [--coverage-php="..."]
 [--phpunit="..."] [--runner="..."] [--bootstrap="..."] [-c|--configuration="..."]
 [-g|--group="..."] [--stop-on-failure] [--log-junit="..."] [--colors] [--path="..."] [path]

ParaTest Usage

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.

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.

<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
         backupStaticAttributes="false"
         bootstrap="../bootstrap.php"
         colors="true"
         convertErrorsToExceptions="true"
         convertNoticesToExceptions="true"
         convertWarningsToExceptions="true"
         processIsolation="false"
         stopOnFailure="false"
         syntaxCheck="false"
        >
    <testsuites>
        <testsuite name="ParaTest Fixtures">
            <directory>./tests/</directory>
        </testsuite>
    </testsuites>
</phpunit>

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:

if (getenv('TEST_TOKEN') !== false) {  // Using partest
    $dbname = 'testdb_' . getenv('TEST_TOKEN');
} else {
    $dbname = 'testdb';
}

Running Tests

ParaTest's test suite depends on PHPUnit being installed via composer. Make sure you run composer install after cloning.

To run unit tests: vendor/bin/phpunit test/ParaTest

To run integration tests: vendor/bin/phpunit it/ParaTest

To run functional tests: vendor/bin/phpunit functional

There are a couple of shortcuts in the bin directory as well.

bin/test for unit tests. bin/test it for integration tests. bin/test functional for functional tests

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.

Something went wrong with that request. Please try again.