View Javadoc
1   package otherTests.testng;
2   
3   import static org.testng.Assert.assertEquals;
4   import static org.testng.Assert.assertNull;
5   
6   import java.applet.Applet;
7   
8   import mockit.Mock;
9   import mockit.MockUp;
10  
11  import org.testng.IHookCallBack;
12  import org.testng.IHookable;
13  import org.testng.ITestResult;
14  import org.testng.annotations.AfterMethod;
15  import org.testng.annotations.BeforeMethod;
16  
17  public class BaseTestNGDecoratorTest implements IHookable {
18      // Makes sure TestNG integration works with test classes which implement IHookable.
19      @Override
20      public void run(IHookCallBack callBack, ITestResult testResult) {
21          callBack.runTestMethod(testResult);
22      }
23  
24      public static class FakeClass1 extends MockUp<Applet> {
25          @Mock
26          public String getAppletInfo() {
27              return "TEST1";
28          }
29      }
30  
31      @BeforeMethod
32      public final void beforeBase() {
33          assertNull(new Applet().getAppletInfo());
34          new FakeClass1();
35          assertEquals(new Applet().getAppletInfo(), "TEST1");
36      }
37  
38      @AfterMethod
39      public final void afterBase() {
40          assertEquals(new Applet().getAppletInfo(), "TEST1");
41      }
42  }