question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mockito JUnit Jupiter extension does not correctly support parallel test execution

See original GitHub issue

Sorry for not being able to provide the required information, but we just noticed that the MockitoExtension (mockito-junit-jupiter 2.24.5) leads to spurious test failures (e.g. due to calls to mocks not being recorded) when using “junit.jupiter.execution.parallel.enabled=true” with surefire. Prior we used our much simpler MockitoExtension which works fine in the same situation:

public class MockitoExtension implements Extension, TestInstancePostProcessor, AfterEachCallback {
   @Override
   public void postProcessTestInstance(Object testInstance, ExtensionContext context) {
      MockitoAnnotations.initMocks(testInstance);
   }

   @Override
   public void afterEach(ExtensionContext extensionContext) throws Exception {
      Mockito.validateMockitoUsage();
   }
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:5
  • Comments:25 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
TimvdLippecommented, Oct 1, 2019

I will publish a release today

1reaction
SchulteMarkuscommented, Oct 1, 2019

I updated https://github.com/SchulteMarkus/mockito.bug1630 - seems to work without problems using Mockito v.3.1.0, thanks a lot! I will delete https://github.com/SchulteMarkus/mockito.bug1630 within a few weeks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

JUnit 5 User Guide
The ExecutionCondition extension API in JUnit Jupiter allows developers to either enable or disable a container or test based on certain ...
Read more >
JUnit 5 Parallel Test Execution - Software Test Academy
This is an experimental feature of JUnit 5 and it will come from after JUnit 5.3. To enable parallel execution, simply set the...
Read more >
Complete JUnit 5 Mockito Tutorial For Unit Testing - LambdaTest
In this JUnit 5 Mockito tutorial, we will see how Mockito can be used ... when implementation of external dependencies is not yet...
Read more >
junit-team/junit5 - Gitter
The idea is to not have to add any annotation or change to existing tests but to ... Jupiter extensions are executed later...
Read more >
How to resolve Unneccessary Stubbing exception
For JUnit 5 tests you can silence this exception using this annotation provided in mockito-junit-jupiter package:
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found