1 package mockit;
2
3 import static org.junit.jupiter.api.Assertions.assertNotNull;
4 import static org.junit.jupiter.api.Assertions.assertNotSame;
5 import static org.junit.jupiter.api.Assertions.assertNull;
6
7 import org.junit.jupiter.api.MethodOrderer.MethodName;
8 import org.junit.jupiter.api.Test;
9 import org.junit.jupiter.api.TestMethodOrder;
10
11
12
13
14 @TestMethodOrder(MethodName.class)
15 final class TestedClassInGlobalScopeTest {
16
17
18
19
20 static class TestedClass {
21
22 Integer someValue;
23 }
24
25
26 @Tested(fullyInitialized = true, global = true)
27 TestedClass testedGlobal;
28
29
30 @Tested(fullyInitialized = true)
31 TestedClass testedLocal;
32
33
34
35
36 @Test
37 void useTestedObjectInFirstStepOfTestedScenario() {
38 assertNull(testedGlobal.someValue);
39 assertNotSame(testedGlobal, testedLocal);
40 testedGlobal.someValue = 123;
41 }
42
43
44
45
46 @Test
47 void useTestedObjectInSecondStepOfTestedScenario() {
48 assertNotNull(testedGlobal.someValue);
49 assertNull(testedLocal.someValue);
50 }
51 }