Note that there are some explanatory texts on larger screens.

plurals
  1. POphpunit testsuite independence
    primarykey
    data
    text
    <p>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.</p> <p>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.</p> <p>So - <em>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?</em> (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.</p> <p>A quick example which illustrates the problem would be a 'constant.php' file:</p> <pre><code>&lt;?php if (defined('XYZZY')) define('TEST', 1); else define('TEST', 2); </code></pre> <p>a testsuite 'TestOne.php':</p> <pre><code>&lt;?php define('XYZZY', ""); require_once('constant.php'); class TestOne extends PHPUnit_Framework_TestCase { public function testOne() { $this-&gt;assertEquals(TEST, 1); } } </code></pre> <p>a similar testsuite 'TestTwo.php':</p> <pre><code>&lt;?php require_once('constant.php'); class TestTwo extends PHPUnit_Framework_TestCase { public function testTwo() { $this-&gt;assertEquals(TEST, 2); } } </code></pre> <p>and a phpunit configuration file:</p> <pre><code>&lt;phpunit&gt; &lt;testsuites&gt; &lt;testsuite name="First"&gt; &lt;file&gt;./TestOne.php&lt;/file&gt; &lt;/testsuite&gt; &lt;testsuite name="Second"&gt; &lt;file&gt;./TestTwo.php&lt;/file&gt; &lt;/testsuite&gt; &lt;/testsuites&gt; &lt;/phpunit&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload