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
Test case skipped when autoloaded before checking #2136
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. |
Thanks for reply. Perhaps the test cases I've used in SuiteTest meet your definition of "minimal, self-contained"? I'll be happy to provide something more appropriate if that's not what you need :) Cheers! |
A a minimal, self-contained, reproducing test case is something short that you can add here in a comment and that I can copy, paste, and run. |
ATest.php
BTest.php
|
I experienced the same problem (using 4.8.24) with a more simple case. If you just declare a constant with value of another not abstract testcase (as shortcut). So ATest.php can be simplified to:
When using a TestSuite that loads ATest.php first, BTest is declared before BTest.php is processed for "addTestFile" and following code will deliver an empty array for $newClasses:
I decided to forbid using constants of other (not abstract) test-classes within my projects, but it can be caused by each autoload-process or require. EDIT: I added a repository with these test cases https://github.com/glady/phpunit_issue_2136 |
I've run into this as well, and was just creating a minimal failing case until I searched through the issues and found this. In our particular case, we were using a data provider from a different test case which triggered the same autoloading bug. Since I already finished the repo, here's another test setup: https://github.com/jeremyharris/phpunit-issue-2136 You'll see that when ATest is autoloaded in BTest before ATest is run, it fails to run the assertions for ATest. |
Please don't autoload test case classes. |
`BeditaShellTest` used to reference a constant defined in `SetupConnectionTaskTest`. This caused the latter class to be autoloaded, which caused the `SetupConnectionTaskTest` case not to be loaded by PHPUnit as per sebastianbergmann/phpunit#2136.
`BeditaShellTest` used to reference a constant defined in `SetupConnectionTaskTest`. This caused the latter class to be autoloaded, which caused the `SetupConnectionTaskTest` case not to be loaded by PHPUnit as per sebastianbergmann/phpunit#2136.
Hi.
Here's a test showing the bug related to autoloading:
https://github.com/paq85/phpunit/blob/master/tests/Framework/SuiteTest.php#L260
Results: https://travis-ci.org/paq85/phpunit/jobs/122711118
I think the issue is in how \PHPUnit_Framework_TestSuite::addTestFile decides if class should be included in test suite.
IMHO it's a bug but if it's an expected behaviour it would be great to have a not about it in the doc and a notice in the command line output.
This may cause some test cases not being executed without any warning - and it's hard to spot.
Thanks.
The text was updated successfully, but these errors were encountered: