01: package test.configuration;
02:
03: import java.lang.reflect.Method;
04: import java.util.HashMap;
05: import java.util.Map;
06:
07: import org.testng.Assert;
08: import org.testng.annotations.AfterClass;
09: import org.testng.annotations.AfterMethod;
10: import org.testng.annotations.BeforeMethod;
11: import org.testng.annotations.Test;
12:
13: /**
14: * This class/interface
15: */
16: public class ReflectMethodParametrizedConfigurationMethodTest {
17: private Map<String, String> m_before = new HashMap<String, String>();
18: private Map<String, String> m_after = new HashMap<String, String>();
19:
20: @BeforeMethod
21: public void beforeMethod(Method tobeInvokedTestMethod) {
22: m_before.put(tobeInvokedTestMethod.getName(),
23: tobeInvokedTestMethod.getName());
24: }
25:
26: @Test
27: public void test1() {
28: }
29:
30: @Test
31: public void test2() {
32: }
33:
34: @AfterMethod
35: public void afterMethod(Method invokedTestMethod) {
36: m_after.put(invokedTestMethod.getName(), invokedTestMethod
37: .getName());
38: }
39:
40: @AfterClass
41: public void assertBeforeAfterMethodsInvocations() {
42: Assert
43: .assertTrue(m_before.containsKey("test1"),
44: "@Test method should have been passed to @BeforeMethod");
45: Assert
46: .assertTrue(m_before.containsKey("test2"),
47: "@Test method should have been passed to @BeforeMethod");
48: Assert.assertTrue(m_after.containsKey("test1"),
49: "@Test method should have been passed to @AfterMethod");
50: Assert.assertTrue(m_before.containsKey("test2"),
51: "@Test method should have been passed to @AfterMethod");
52: }
53: }
|