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

Guard against multiple evaluations of before statement #1821

Conversation

marcphilipp
Copy link
Contributor

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.

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.
Copy link
Contributor

@TimvdLippe TimvdLippe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense, thanks for reaching out again and fixing it!!

@TimvdLippe
Copy link
Contributor

Oh, this fails a lot of tests 😢 Could it be that testFinished needs the same treatment?

@marcphilipp
Copy link
Contributor Author

Could it be that testFinished needs the same treatment?

It does indeed. 👍

@codecov-io
Copy link

codecov-io commented Nov 10, 2019

Codecov Report

Merging #1821 into release/3.x will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@                Coverage Diff                @@
##             release/3.x    #1821      +/-   ##
=================================================
+ Coverage          86.71%   86.71%   +<.01%     
  Complexity          2492     2492              
=================================================
  Files                311      311              
  Lines               6549     6551       +2     
  Branches             821      822       +1     
=================================================
+ Hits                5679     5681       +2     
  Misses               674      674              
  Partials             196      196
Impacted Files Coverage Δ Complexity Δ
...ockito/internal/runners/DefaultInternalRunner.java 100% <100%> (ø) 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 2ffc8ae...49e41aa. Read the comment docs.

@TimvdLippe
Copy link
Contributor

Awesome thanks!

@TimvdLippe TimvdLippe merged commit d64cbd3 into mockito:release/3.x Nov 10, 2019
@marcphilipp marcphilipp deleted the issues/1767-guard-against-multiple-statement-evaluations branch November 11, 2019 06:50
epeee pushed a commit to epeee/mockito that referenced this pull request Jun 22, 2020
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

'MismatchReportingTestListener' has already been added and not removed using MockitoJUnitRunner
3 participants