View Javadoc
1   /*
2    * MIT License
3    * Copyright (c) 2006-2025 JMockit developers
4    * See LICENSE file for full license text.
5    */
6   package mockit;
7   
8   import static org.junit.jupiter.api.Assertions.assertSame;
9   
10  import mockit.integration.junit5.JMockitExtension;
11  
12  import org.junit.jupiter.api.Test;
13  import org.junit.jupiter.api.extension.ExtendWith;
14  
15  class BaseTestClass {
16      static final class Dependency {
17      }
18  
19      @Tested
20      final Dependency dependency = new Dependency();
21  }
22  
23  /**
24   * The Class TestedClassInjectedFromBaseTest.
25   */
26  @ExtendWith(JMockitExtension.class)
27  class TestedClassInjectedFromBaseTest extends BaseTestClass {
28  
29      /**
30       * The Class TestedClass.
31       */
32      static final class TestedClass {
33          /** The dependency. */
34          Dependency dependency;
35      }
36  
37      /** The tested. */
38      @Tested(fullyInitialized = true)
39      TestedClass tested;
40  
41      /**
42       * Verify tested object injected with tested dependency provided by base test class.
43       */
44      @Test
45      void verifyTestedObjectInjectedWithTestedDependencyProvidedByBaseTestClass() {
46          assertSame(dependency, tested.dependency);
47      }
48  }