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
Report initialization failures per test method #1672
Conversation
Prior to this commit, `DefaultInternalRunner` threw an exception when `MockitoAnnotations.initMocks()` failed from the overridden `withBefores` method. Instead, it now returns a `Statement` that is responsible for initializing. Potential exceptions are then handled by JUnit, regardless whether version 4.12 or 4.13-beta-2 is used. Instead of reporting a class-level error, JUnit will now report a failure for each test method in such test classes. Related issue: junit-team/junit4#1599
Codecov Report
@@ Coverage Diff @@
## release/2.x #1672 +/- ##
=================================================
+ Coverage 87.38% 87.39% +0.01%
Complexity 2446 2446
=================================================
Files 302 302
Lines 6326 6325 -1
Branches 788 787 -1
=================================================
Hits 5528 5528
Misses 603 603
+ Partials 195 194 -1
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this @marcphilipp ! It is a minor change in event firing, but I think it is better to be consistent about it with both 4.12 and 4.13. Merging 😄
Some rules evaluate the base statement multiple times, e.g. to execute tests repeatedly. The changes made in mockito#1672 led to an exception in such cases because the `MockitoListener` was registered multiple times. Now, we only add the listener the first time the statement is evaluated in order to restore the old behavior. Fixes mockito#1767.
* Guard against multiple evaluations of before statement Some rules evaluate the base statement multiple times, e.g. to execute tests repeatedly. The changes made in #1672 led to an exception in such cases because the `MockitoListener` was registered multiple times. Now, we only add the listener the first time the statement is evaluated in order to restore the old behavior. Fixes #1767. * Reset listener when removing it
* Guard against multiple evaluations of before statement Some rules evaluate the base statement multiple times, e.g. to execute tests repeatedly. The changes made in mockito#1672 led to an exception in such cases because the `MockitoListener` was registered multiple times. Now, we only add the listener the first time the statement is evaluated in order to restore the old behavior. Fixes mockito#1767. * Reset listener when removing it
Prior to this commit,
DefaultInternalRunner
threw an exception whenMockitoAnnotations.initMocks()
failed from the overriddenwithBefores
method. Instead, it now returns aStatement
that isresponsible for initializing. Potential exceptions are then handled by
JUnit, regardless whether version 4.12 or 4.13-beta-2 is used. Instead
of reporting a class-level error, JUnit will now report a failure for
each test method in such test classes.
Related issue: junit-team/junit4#1599
including project members to get a better picture of the change
commit is meaningful and help the people that will explore a change in 2 years
Fixes #<issue number>
in the description if relevantFixes #<issue number>
if relevant