-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tests from test class with same non-fully qualified class name as another test class are sometimes not discovered #5287
Comments
Thank you for your report. Please provide a minimal, self-contained, reproducing test case that shows the problem you are reporting. Without such a minimal, self-contained, reproducing test case I will not be able to investigate this issue. |
Took me a while to isolate the problem, but here it is: phpunit10_bug.zip composer install
vendor/bin/phpunit tests/ Tests are passing while |
The event stream confirms that
The problem does not exist in PHPUnit 9.6:
|
This is related to the data provider in class AnotherClassTest extends TestCase
{
- public static function provide(): array
+ public function test(): void
{
- return [[new MyClassTest('a')]];
- }
-
- /** @dataProvider provide */
- public function test(mixed $className): void
- {
- $this->assertInstanceOf(MyClassTest::class, $className);
+ $this->assertTrue(true);
}
} ... then all three test methods are found and run as intended. |
Before I invest time to further investigate this issue, however, I would like to know whether there is a real use case that triggers this issue. Creating a This issue is likely just one more reason to use static analysis instead of dynamic reflection for test discovery. Such a change is a long(er) term project, though. |
@realFlowControl In the meantime, can I bother you to have a look? Maybe you have an idea what should be done here. Thanks! |
I added a test case for this in b7569ec. |
My real use case is using a public static method (instead of dummy class creation): class AnotherClassTest extends TestCase
{
public static function provide(): array
{
- return [[new MyClassTest('a')]];
+ return [[MyClassTest::getVal()]];
}
/** @dataProvider provide */
public function test(mixed $className): void
{
$this->assertEquals('', $className);
}
} |
That was quick, thanks! |
Summary
Not sure to understand what happen, but since I updated one of my project to PHPUnit 10, I got some conflicts with test classes having same names but in different namespaces (I'm using some obscur static mecanisms).
Let say class
\MyTests\A\MyClassTest
and\MyTests\B\MyClassTest
having common\MyTests\C\MyTestCasse
parent for example.I tried to investigate a little bit, and found this line is overriding
$suiteClassName
using first loaded class having same name, whatever namespace is. Is it expected ?Thanks!
The text was updated successfully, but these errors were encountered: