-
-
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
Abstract *Test classes cannot be found #4979
Comments
Correct.
Agreed. |
I think this should produce a deprecation warning in 9.5 branch so that users are informed about this change in advance. phpunit/src/Framework/TestSuite.php Line 457 in a4246d5
|
Thank you for fixing this issue! |
Any chance you @sebastianbergmann can share why that change was introduced? I assume there are many projects following this obvious inheritance and naming scheme. I find it weird that, after years of compatibility, the test framework now forces me to rename them. Would be "less painful" 😁 if we would understand what the technical reason for that change was. The original issue #5132 does not share any insights. |
One note: If you have files (with |
Since version 10, PHPUnit complains about: 1) Your XML configuration validates against a deprecated schema. Migrate your XML configuration using "--migrate-configuration"! 2) Class AltAutoloadTest cannot be found in D:\a\pdfparser\pdfparser\tests\AltAutoloadTest.php 3) Class Tests\Smalot\PdfParser\Performance\Test\AbstractPerformanceTest cannot be found in D:\a\pdfparser\pdfparser\tests\Performance\Test\AbstractPerformanceTest.php 4) Class Tests\Smalot\PdfParser\Performance\Test\DocumentDictionaryCacheTest cannot be found in D:\a\pdfparser\pdfparser\tests\Performance\Test\DocumentDictionaryCacheTest.php The first one is easy to solve. But the other 3 are confusing, because PHPUnit 9 did not complain at all. Reason for these warnings is that since PHPUnit v10, it doesn't like abstract Test classes or files (containing Test in the name), which contain no class at all. Source: sebastianbergmann/phpunit#4979 To mitigate these warnings and to make maintenance easier in the future, I reorganized our test files and put them in different folders. PHPUnit tests are separated from our other tests.
) * Fixes failing tests; reorganized test files (PHPUnit 10.x related) Since version 10, PHPUnit complains about: 1) Your XML configuration validates against a deprecated schema. Migrate your XML configuration using "--migrate-configuration"! 2) Class AltAutoloadTest cannot be found in D:\a\pdfparser\pdfparser\tests\AltAutoloadTest.php 3) Class Tests\Smalot\PdfParser\Performance\Test\AbstractPerformanceTest cannot be found in D:\a\pdfparser\pdfparser\tests\Performance\Test\AbstractPerformanceTest.php 4) Class Tests\Smalot\PdfParser\Performance\Test\DocumentDictionaryCacheTest cannot be found in D:\a\pdfparser\pdfparser\tests\Performance\Test\DocumentDictionaryCacheTest.php The first one is easy to solve. But the other 3 are confusing, because PHPUnit 9 did not complain at all. Reason for these warnings is that since PHPUnit v10, it doesn't like abstract Test classes or files (containing Test in the name), which contain no class at all. Source: sebastianbergmann/phpunit#4979 To mitigate these warnings and to make maintenance easier in the future, I reorganized our test files and put them in different folders. PHPUnit tests are separated from our other tests. * fixed alt autoloading * reverted name change for AbstractPerformanceTest * migrated Windows-related PHPUnit config file * dev-tools: restrict PHPUnit version in composer.json * Update dev-tools/composer.json Co-authored-by: Jérémy Benoist <[email protected]> --------- Co-authored-by: Jérémy Benoist <[email protected]>
Summary
I wanted to try out PHPUnit 10-dev on a project that has a green and (almost) deprecation-free test suite running on PHPUnit 9.5. In that project, there are several abstract classes following the naming convention
AbstractSomethingTest
. Then there are non-abstract child classes which are actually executable test cases.When running PHPUnit 10, it crashes on the first of those abstract classes, claiming that it could not find the class:
Stacktrace redacted to remove references to the actual project. I could provide a minimal reproducer if necessary.
This error message is pretty odd because the class PHPUnit complains about is defined exactly in the file mentioned in the exception message.
If I rename that one class from
AbstractSomethingTest
toSomethingTestCase
and run PHPUnit again, it crashes on the next class following that pattern. If I rename all of the affected classes, PHPUnit runs fine.Apparently, PHPUnit does not like abstract classes anymore that use the
Test
suffix. I wasn't sure if this was an intended breaking change or not, but I could not find documentation on this. Renaming those classes wouldn't be a big deal in my case (it would only affect 10 or so classes). But if this is really an intentional change, I believe something must be done about the error message at least because that message is highly misleading.The text was updated successfully, but these errors were encountered: