View Javadoc
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   * The Class TestedClassInGlobalScopeTest.
13   */
14  @TestMethodOrder(MethodName.class)
15  final class TestedClassInGlobalScopeTest {
16  
17      /**
18       * The Class TestedClass.
19       */
20      static class TestedClass {
21          /** The some value. */
22          Integer someValue;
23      }
24  
25      /** The tested global. */
26      @Tested(fullyInitialized = true, global = true)
27      TestedClass testedGlobal;
28  
29      /** The tested local. */
30      @Tested(fullyInitialized = true)
31      TestedClass testedLocal;
32  
33      /**
34       * Use tested object in first step of tested scenario.
35       */
36      @Test
37      void useTestedObjectInFirstStepOfTestedScenario() {
38          assertNull(testedGlobal.someValue);
39          assertNotSame(testedGlobal, testedLocal);
40          testedGlobal.someValue = 123;
41      }
42  
43      /**
44       * Use tested object in second step of tested scenario.
45       */
46      @Test
47      void useTestedObjectInSecondStepOfTestedScenario() {
48          assertNotNull(testedGlobal.someValue);
49          assertNull(testedLocal.someValue);
50      }
51  }