I am running a series of tests in phpunit which exist in separate testsuites, the list of which is controlled by a phpunit configuration file. When the tests are run individually (i.e. not through the configuration file and hence a since testsuite at a time) they pass but, when run together, I get a failure.
On close examination the issue is that each of these testsuite is loading in a framework (via a require_once) and that framework does some internal configuration based on settings at the time of the require_once. It would appear that, between running the testsuites separately listed in the phpunit configuration file, various things persist. In this particular case the framework is already viewed as loaded.
So - is there a way of getting phpunit to execute a sequence of testsuites independently, i.e. equivalently to running phpunit on the testsuites one at a time? (phpunit is being triggered by cruisecontrol on an autotest machine and locally by developers before submissions.) I've tried options such as '--process-isolation' and '--no-globals-backup' without success.
A quick example which illustrates the problem would be a 'constant.php' file:
<?php
if (defined('XYZZY')) define('TEST', 1);
else define('TEST', 2);
a testsuite 'TestOne.php':
<?php
define('XYZZY', "");
require_once('constant.php');
class TestOne extends PHPUnit_Framework_TestCase
{
public function testOne()
{
$this->assertEquals(TEST, 1);
}
}
a similar testsuite 'TestTwo.php':
<?php
require_once('constant.php');
class TestTwo extends PHPUnit_Framework_TestCase
{
public function testTwo()
{
$this->assertEquals(TEST, 2);
}
}
and a phpunit configuration file:
<phpunit>
<testsuites>
<testsuite name="First">
<file>./TestOne.php</file>
</testsuite>
<testsuite name="Second">
<file>./TestTwo.php</file>
</testsuite>
</testsuites>
</phpunit>