-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Labels
Description
| Q | A |
|---|---|
| PHPUnit version | 9.1.4 |
| PHP version | 7.3 |
| Installation Method | Both Composer and PHAR |
Summary
When the current test class (e.g. FooTest) extends the parent class with a partially matching name (ending with FooTest, for example ParentFooTest, AbstractFooTest or similar), the testsuite loader does not run any tests and produces a warning:
<?php
class FooTest extends ParentFooTest
{
public function testSomething()
{
static::assertTrue(true);
}
}
$ vendor/bin/phpunit tests/FooTest.php
PHPUnit 9.1.4 by Sebastian Bergmann and contributors.
W 1 / 1 (100%)
Time: 00:00.026, Memory: 6.00 MB
There was 1 warning:
1) Warning
No tests found in class "App\Tests\ParentFooTest".
WARNINGS!
Tests: 1, Assertions: 0, Warnings: 1.
Current behavior
phpunit/src/Runner/StandardTestSuiteLoader.php
Lines 44 to 48 in 1dc40a5
| $offset = 0 - \strlen($suiteClassName); | |
| foreach ($loadedClasses as $loadedClass) { | |
| if (\substr($loadedClass, $offset) === $suiteClassName) { | |
| $suiteClassName = $loadedClass; |
How to reproduce
Here is the reproducer - https://github.com/mbessolov/phpunit-loader-bug
Expected behavior
It should not matter if there is any partial similary between the names of the current test class and any of its parents.