01: package test.configuration;
02:
03: import org.testng.Assert;
04: import org.testng.ITestContext;
05: import org.testng.ITestNGMethod;
06: import org.testng.annotations.BeforeMethod;
07: import org.testng.annotations.Test;
08:
09: import java.lang.reflect.Method;
10:
11: public class BeforeMethodTest {
12: private Method m_method;
13: private ITestContext m_context;
14:
15: @BeforeMethod
16: public void before(Method m, ITestContext ctx) {
17: m_method = m;
18: m_context = ctx;
19: }
20:
21: @Test
22: public void mainTest() {
23: Assert.assertEquals(m_method.getName(), "mainTest");
24: ITestNGMethod[] methods = m_context.getAllTestMethods();
25: Assert.assertEquals(1, methods.length);
26: Assert.assertEquals(methods[0].getMethod().getName(),
27: "mainTest");
28:
29: }
30: }
|