Mockito JUnit Jupiter extension does not correctly support parallel test execution
See original GitHub issueSorry 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:
- Created 5 years ago
- Reactions:5
- Comments:25 (11 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I will publish a release today
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.