Skip to content

Commit 5275579

Browse files
authored
Update README.md
1 parent cf44e37 commit 5275579

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ This JUnit5 extension allows you to arbitrarily set any field on your `@InjectMo
5656
import com.github.exabrial.junit5.injectmap.InjectionMap;
5757
import com.github.exabrial.junit5.injectmap.InjectMapExtension;
5858
59-
@TestInstance(Lifecycle.PER_CLASS)
59+
@TestInstance(Lifecycle.PER_METHOD)
6060
@ExtendWith({ MockitoExtension.class, InjectMapExtension.class })
6161
public class MyControllerTest {
6262
@InjectMocks
@@ -120,4 +120,4 @@ Maven Coordinates:
120120
</dependency>
121121
```
122122

123-
The final note is that it should extraordinarily obvious that per-test forking will produce undefined results when using `@InjectMocks`, and as such, per-test forking is not thread-safe for this test extension. Hence the `@TestInstance(Lifecycle.PER_CLASS)` on the example.
123+
The final note is that it should extraordinarily obvious that multithreading on the same test instances will cause problems. Set your forking policies accordingly to avoid race conditions.

0 commit comments

Comments
 (0)