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

Report initialization failures per test method #1672

Merged
merged 1 commit into from Mar 23, 2019

Conversation

@marcphilipp
Copy link
Contributor

marcphilipp commented Mar 23, 2019

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

  • Read the contributing guide
  • PR should be motivated, i.e. what does it fix, why, and if relevant how
  • If possible / relevant include an example in the description, that could help all readers
    including project members to get a better picture of the change
  • Avoid other runtime dependencies
  • Meaningful commit history ; intention is important please rebase your commit history so that each
    commit is meaningful and help the people that will explore a change in 2 years
  • The pull request follows coding style
  • Mention Fixes #<issue number> in the description if relevant
  • At least one commit should mention Fixes #<issue number> if relevant
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-io

This comment has been minimized.

Copy link

codecov-io commented Mar 23, 2019

Codecov Report

Merging #1672 into release/2.x will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@                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
Impacted Files Coverage Δ Complexity Δ
...ockito/internal/runners/DefaultInternalRunner.java 100% <100%> (+3.22%) 4 <0> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7c8aae0...49e6311. Read the comment docs.

Copy link
Contributor

TimvdLippe left a comment

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 😄

@TimvdLippe TimvdLippe merged commit d84bcb5 into mockito:release/2.x Mar 23, 2019
3 checks passed
3 checks passed
codecov/patch 100% of diff hit (target 87.38%)
Details
codecov/project 87.39% (+0.01%) compared to 7c8aae0
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
marcphilipp added a commit to marcphilipp/mockito that referenced this pull request Nov 10, 2019
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.
TimvdLippe added a commit that referenced this pull request Nov 10, 2019
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.