• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package test.hook;
2 
3 import org.testng.IHookCallBack;
4 import org.testng.IHookable;
5 import org.testng.ITestResult;
6 import org.testng.Reporter;
7 import org.testng.annotations.DataProvider;
8 import org.testng.annotations.Test;
9 
10 /**
11  * Test harness for {@link IHookable}
12  *
13  * @author <a href="mailto:cedric@beust.com">Cedric Beust</a>
14  * @since Aug 01, 2006
15  */
16 public class HookSuccessTest implements IHookable {
17   static boolean m_hook = false;
18   static boolean m_testWasRun = false;
19   static String m_parameter = null;
20 
21   @Override
run(IHookCallBack callBack, ITestResult testResult)22   public void run(IHookCallBack callBack, ITestResult testResult) {
23     m_hook = true;
24     Object[] parameters = callBack.getParameters();
25     if (parameters.length > 0) {
26       m_parameter = parameters[0].toString();
27     }
28     callBack.runTestMethod(testResult);
29   }
30 
31   @DataProvider
dp()32   public Object[][] dp() {
33     return new Object[][] {
34         new Object[] { "foo" }
35     };
36   }
37 
38   @Test(dataProvider = "dp")
verify(String name)39   public void verify(String name) {
40     m_testWasRun = true;
41     Reporter.log("output from hook test.verify");
42   }
43 
44 //  @AfterMethod
45 //  public void tearDown() {
46 //    Assert.assertTrue(m_hook);
47 //    Assert.assertTrue(m_testWasRun);
48 //  }
49 
ppp(String string)50   private void ppp(String string) {
51     System.out.println("[HookTest] " + string);
52   }
53 
54 }
55