Home » Testing » PHPUnit2 » Bug #7930
TestSuite does not find Tests in Files correctly when using addTestFile.
Details
| Submitted | 2006-06-17 16:52 UTC |
|---|---|
| From | latency at gmx dot de |
| Status | Suspended |
| Package | PHPUnit2 |
| PHP Version | Irrelevant |
| OS | Linux Kernel-SMP 2.6 |
| Roadmaps | (Not assigned) |
Comments
[2006-06-17 16:52 UTC] latency at gmx dot de
Description:
------------
A TestSuite only findes Tests in Files if they have a class-name ending with "Test". All other classes won't be recognized as a test.
On the other hand classes named "XyzTest" that do not implement the Test Interface will be regarded as valid Tests, the Runner tries to run them but then failes in a fatal error.
Test script:
---------------
/*** File: SomeTests.php ***/
class test_Whatever extends PHPUnit2_Framework_TestCase {
// Regular implemented test code.
}
class FakeTest {
public function __construct() {
// Needs a public otherwise an PHPUnit2_Framework_Warning will occure
}
public function testFake() {
}
}
/*** File: MySuite.php ***/
$suite = new PHPUnit2_Framework_TestSuite("ExampleSuite");
$suite->addTestFile("SomeTests.php");
$suite->run();
Expected result:
----------------
The class test_Valid would be run properly and FakeTest should be ignored.
Actual result:
--------------
PHPUnit2 ignores test_Valid and tries to run FakeTest. This will result in a fatal error with message:
PHP Fatal error: Argument 1 passed to PHPUnit2_Framework_TestSuite::addTest() must implement interface PHPUnit2_Framework_Test, called in PHPUnit2/Framework/TestSuite.php on line 548 and defined in PHPUnit2/Framework/TestSuite.php on line 227
[2006-07-05 15:33 UTC] sebastian at php dot net
Moved to http://www.phpunit.de/ticket/5.