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

JUnit 5 strict stubs check should not suppress the regular test failure #1928

Merged

Conversation

andreisilviudragnea
Copy link
Contributor

If the test fails, MockitoExtension should not check for strict stubs at the end of the test, because the possible UnnecessaryStubbingException will end up as a suppressed exception on the test's initial failure.

If the test fails, MockitoExtension should not check
for strict stubs at the end of the test.
@TimvdLippe TimvdLippe requested a review from mockitoguy May 8, 2020 20:36
@mockitoguy
Copy link
Member

Good idea. Will review shortly. Thank you for the contribution!

Copy link
Member

@mockitoguy mockitoguy left a comment

Choose a reason for hiding this comment

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

Really nice change thank you! Can you address my feedback? Looking forward to merging it!


assertThat(result.getStatus()).isEqualTo(TestExecutionResult.Status.FAILED);
Throwable throwable = result.getThrowable().get();
assertThat(throwable).isInstanceOf(AssertionError.class);
Copy link
Member

Choose a reason for hiding this comment

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

Can you make the assertion stronger by using a more specific exception? You can create a custom exception type in the test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I see you already did it.

Copy link
Member

Choose a reason for hiding this comment

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

Yes ;)

@codecov-io
Copy link

Codecov Report

Merging #1928 into release/3.x will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@              Coverage Diff               @@
##             release/3.x    #1928   +/-   ##
==============================================
  Coverage          86.67%   86.67%           
  Complexity          2526     2526           
==============================================
  Files                318      318           
  Lines               6650     6650           
  Branches             832      832           
==============================================
  Hits                5764     5764           
  Misses               685      685           
  Partials             201      201           
Impacted Files Coverage Δ Complexity Δ
...va/org/mockito/junit/jupiter/MockitoExtension.java 93.33% <100.00%> (ø) 10.00 <0.00> (ø)

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 121dafa...c86d015. Read the comment docs.

@mockitoguy mockitoguy changed the title Fix JUnit 5 strict stubs check on test failure JUnit 5 strict stubs should not suppress the regular test failure May 14, 2020
@mockitoguy mockitoguy changed the title JUnit 5 strict stubs should not suppress the regular test failure JUnit 5 strict stubs check should not suppress the regular test failure May 14, 2020
@mockitoguy mockitoguy merged commit 356228a into mockito:release/3.x May 14, 2020
@andreisilviudragnea andreisilviudragnea deleted the fix-junit5-strict-stubs branch May 17, 2020 10:33
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.

None yet

3 participants