1 package mockit.integration.junit4; 2 3 import static org.junit.jupiter.api.Assertions.assertEquals; 4 5 import mockit.Mock; 6 import mockit.MockUp; 7 8 import org.junit.BeforeClass; 9 import org.junit.Test; 10 11 public final class SecondJUnit4DecoratorTest { 12 public static final class RealClass3 { 13 public String getValue() { 14 return "REAL3"; 15 } 16 } 17 18 public static final class FakeClass3 extends MockUp<RealClass3> { 19 @Mock 20 public String getValue() { 21 return "TEST3"; 22 } 23 } 24 25 @BeforeClass 26 public static void setUpFakes() { 27 new FakeClass3(); 28 } 29 30 @Test 31 public void realClassesFakedInPreviousTestClassMustNoLongerBeFaked() { 32 assertEquals("REAL0", new BaseJUnit4DecoratorTest.RealClass0().getValue()); 33 assertEquals("REAL1", new BaseJUnit4DecoratorTest.RealClass1().getValue()); 34 assertEquals("REAL2", new JUnit4DecoratorTest.RealClass2().getValue()); 35 } 36 37 @Test 38 public void useClassScopedFakeDefinedForThisClass() { 39 assertEquals("TEST3", new RealClass3().getValue()); 40 } 41 }