Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1806 from mockito/sf2
Fixed JUnit5 concurrency bug
- Loading branch information
Showing
2 changed files
with
94 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
subprojects/junitJupiterParallelTest/src/test/java/org/mockito/NestedParallelTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* Copyright (c) 2019 Mockito contributors | ||
* This program is made available under the terms of the MIT License. | ||
*/ | ||
package org.mockito; | ||
|
||
import org.junit.jupiter.api.Nested; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class NestedParallelTest { | ||
|
||
@Mock | ||
private SomeService someService; | ||
|
||
@InjectMocks | ||
private AnotherService anotherService; | ||
|
||
@Nested | ||
class NestedTest { | ||
|
||
@Test | ||
void test() { | ||
perform(); | ||
} | ||
|
||
private void perform() { | ||
// when | ||
anotherService.callSomeService(); | ||
|
||
// then | ||
Mockito.verify(someService).doSomething(); | ||
} | ||
|
||
@Test | ||
void test2() { | ||
perform(); | ||
} | ||
|
||
@Test | ||
void test3() { | ||
perform(); | ||
} | ||
|
||
@Test | ||
void test4() { | ||
perform(); | ||
} | ||
|
||
@Test | ||
void test5() { | ||
perform(); | ||
} | ||
|
||
@Test | ||
void test6() { | ||
perform(); | ||
} | ||
|
||
@Test | ||
void test7() { | ||
perform(); | ||
} | ||
} | ||
|
||
public static class AnotherService { | ||
private final SomeService someService; | ||
|
||
public AnotherService(final SomeService someService) { | ||
this.someService = someService; | ||
} | ||
|
||
void callSomeService() { | ||
someService.doSomething(); | ||
} | ||
} | ||
|
||
static class SomeService { | ||
|
||
void doSomething() { | ||
} | ||
} | ||
} |