1
2
3
4
5
6 package otherTests.testng;
7
8 import static org.testng.Assert.assertEquals;
9 import static org.testng.Assert.assertNull;
10
11 import mockit.Mock;
12 import mockit.MockUp;
13
14 import org.testng.IHookCallBack;
15 import org.testng.IHookable;
16 import org.testng.ITestResult;
17 import org.testng.annotations.AfterMethod;
18 import org.testng.annotations.BeforeMethod;
19
20 public class BaseTestNGDecoratorTest implements IHookable {
21
22 @Override
23 public void run(IHookCallBack callBack, ITestResult testResult) {
24 callBack.runTestMethod(testResult);
25 }
26
27
28 public static class SimpleComponent {
29 public String getInfo() {
30 return null;
31 }
32 }
33
34 public static class FakeClass1 extends MockUp<SimpleComponent> {
35 @Mock
36 public String getInfo() {
37 return "TEST1";
38 }
39 }
40
41 @BeforeMethod
42 public final void beforeBase() {
43 assertNull(new SimpleComponent().getInfo());
44 new FakeClass1();
45 assertEquals(new SimpleComponent().getInfo(), "TEST1");
46 }
47
48 @AfterMethod
49 public final void afterBase() {
50 assertEquals(new SimpleComponent().getInfo(), "TEST1");
51 }
52 }