phpunit icon indicating copy to clipboard operation
phpunit copied to clipboard

Tests for test suite reordering fail

Open sebastianbergmann opened this issue 1 month ago • 5 comments

I pulled #6338 into 10.5 and merged it from there to 11.5, 12.4, 12.5, and main.

On PHPUnit >= 12, two tests, order-by-defects-test-classes-with-defects.phpt and order-by-defects-test-methods-with-defects.phpt, now fail.

These test failures need to be investigated. Hopefully, these tests fail for the obvious reason: that the result cache fixture file needs to be updated.

sebastianbergmann avatar Nov 21 '25 13:11 sebastianbergmann

@staabm I can't see the forest for the trees at the moment, maybe a fresh pair of eyes is needed? Could you take a look? Thanks!

sebastianbergmann avatar Nov 21 '25 13:11 sebastianbergmann

Looking at tests/end-to-end/execution-order/order-by-defects-test-classes-with-defects.phpt, I wonder why the expectation is that after the 2 failled tests namely testThree and testTwo - the 2 succeeding tests are expected in the order testFour, testOne.

shouldn't they be executed in the order of declaration in the test-class, which means testOne before testFour (and thats what the test runner in PHPUnit 12.x is doing)

I guess what I am saying is, that the tests looks for me to work like expected starting with 12.x. maybe I miss something?

staabm avatar Nov 25 '25 06:11 staabm

Thank you for your feedback, I did not think of this possibility.

As explained in https://github.com/sebastianbergmann/phpunit/pull/6338#issue-3359042338, to me, these new tests are characterization tests meaning they characterize the current behaviour. If you are correct, then the characterization tests I originally wrote for PHPUnit 10 now show us that PHPUnit 12 behaves differently.

sebastianbergmann avatar Nov 25 '25 06:11 sebastianbergmann

One PR I remember related to sorting is https://github.com/sebastianbergmann/phpunit/pull/6263

which landed in PHPUnit 11.5+, which means at least for cases which use data-provider there might be a difference between PHPUnit 10 and PHPUnit 11+ (but this does not explain the difference we see regarding the above comments)

staabm avatar Nov 25 '25 06:11 staabm

The new tests work as-is for both PHPUnit 10 and PHPUnit 11, so the PR you mention is unrelated.

sebastianbergmann avatar Nov 25 '25 06:11 sebastianbergmann