Skip to content
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

TestCase::addToAssertionCount() no longer has effect when called from TestListener::endTest() #2758

Closed
havvg opened this issue Aug 15, 2017 · 6 comments
Assignees
Labels
type/backward-compatibility Something will be/is intentionally broken

Comments

@havvg
Copy link

havvg commented Aug 15, 2017

Q A
PHPUnit version 6.3
PHP version 7.0
Installation Method Composer

I upgraded from PHPUnit 5.7 to 6.3 and the TestListener are not executed in the order as before, however there is no mention about this change in behavior in the changes files.

I wrapped the Mockery listener, and got it working with 6.3, but in TestResult::run the addFailure adding 'This test did not perform any assertions' is now run before the TestListener::endTest, which is used to add additional number of assertions to the result.

Please advice – what's the proper way of handling such use cases?

@sebastianbergmann
Copy link
Owner

Can you please clarify what you mean by "the TestListener are not executed in the order as before"?

@havvg
Copy link
Author

havvg commented Aug 15, 2017

What I mean by that: with 5.7 the endTest could call addToAssertionCount which was part of the result; after upgrading to 6.3 this is not true anymore, instead the test is marked risky with message This test did not perform any assertions afterwards the listener would be called and add to the assertion counts.

@sebastianbergmann sebastianbergmann changed the title TestListener not part of the TestResult anymore TestCase::addToAssertionCount() no longer has effect when called from TestListener::endTest() Aug 18, 2017
@sebastianbergmann sebastianbergmann added the type/bug Something is broken label Aug 18, 2017
sebastianbergmann added a commit that referenced this issue Aug 18, 2017
@sebastianbergmann
Copy link
Owner

I added a test for this issue that passes (as expected) with PHPUnit 5.7 and currently fails (as reported) with PHPUnit 6.3.

@sebastianbergmann
Copy link
Owner

The obvious solution of simply calling TestListener::endTest() earlier makes this new test pass with PHPUnit 6.3 but breaks other tests.

@sebastianbergmann sebastianbergmann self-assigned this Aug 18, 2017
@havvg
Copy link
Author

havvg commented Aug 20, 2017

Yeah, I thought so. I don't think there will be a nice way to fix that without breaking ^6.0 again. Therefore I would suggest to add this BC break to the change log. Mockery added a trait using assertPostConditions which yields the expected result.

@sebastianbergmann
Copy link
Owner

Yes, assertPostConditions() is the better approach here. Okay, I'll close this and remove the test I added in 3bfbdd9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/backward-compatibility Something will be/is intentionally broken
Projects
None yet
Development

No branches or pull requests

2 participants