For many good reasons I put some tests into parent test class und some tests in inhereted class. I have got this structure then:
/bar/foo/foo.php
/bar.php
This command I use to start phpunit: phpunit --configuration unit.xml
I tried this one too, but with same result: phpunit --configuration unit.xml --testsuite foo
So now I want to run all tests in a folder foo. Problem is, that tests in bar.php
will be running twice and I have no idea why. Do someone has the answer to that? Is it maybe a feature of phpunit? How can I told phpunit not to run them twice?
If I run phpunit bar/foo/foo.php
everything works fine and test function in bar.php
is running only once.
foo.php
require_once '/bar.php';
class foo_test extends bar_test {
public function test_1_pass() {
$this->assertEquals('a', 'a');
}
}
bar.php
class bar_test extends PHPUnit_Framework_TestCase {
public function test_2_fail() {
$this->assertEquals('a', 'b');
}
}
Unittest responce
PHPUnit 3.7.29 by Sebastian Bergmann.
Configuration read from /unit.xml
F.F
Time: 104 ms, Memory: 3.25Mb
There were 2 failures:
1) bar_test::test_2_fail
Failed asserting that two strings are equal.
/bar.php:6
2) foo_test::test_2_fail
Failed asserting that two strings are equal.
/bar.php:6
FAILURES!
Tests: 3, Assertions: 3, Failures: 2.
unit.xml
<phpunit
backupGlobals="false"
backupStaticAttributes="false"
syntaxCheck="false">
<testsuites>
<testsuite name="foo">
<directory suffix=".php">bar/foo</directory>
</testsuite>
</testsuites>
</phpunit>