1 package mockit.integration.junit4; 2 3 import static org.junit.jupiter.api.Assertions.assertFalse; 4 import static org.junit.jupiter.api.Assertions.assertTrue; 5 6 import org.junit.Test; 7 8 public final class UseDependencyTest { 9 @Test 10 public void useMockedDependency() { 11 if (AnotherDependency.mockedAtSuiteLevel) { 12 assertFalse(AnotherDependency.alwaysTrue()); 13 } else { 14 assertTrue(AnotherDependency.alwaysTrue()); 15 } 16 } 17 18 private static final boolean STATIC_FIELD = Dependency.alwaysTrue(); 19 private final boolean instanceField = Dependency.alwaysTrue(); 20 21 @Test 22 public void useFieldSetThroughDirectInstanceInitializationRatherThanBeforeMethod() { 23 assertTrue(instanceField, "Dependency still mocked"); 24 } 25 26 @Test 27 public void useFieldSetThroughDirectClassInitializationRatherThanBeforeClassMethod() { 28 assertTrue(STATIC_FIELD, "Dependency still mocked"); 29 } 30 }