我想获取当前正在执行的测试方法@Before
这样我就可以将注释应用于当前正在执行的方法。
public class TestCaseExample {
@Before
public void setUp() {
// get current method here.
}
@Test
@MyAnnotation("id")
public void someTest {
// code
}
}
尝试 TestName 规则
public class TestCaseExample {
@Rule
public TestName testName = new TestName();
@Before
public void setUp() {
Method m = TestCaseExample.class.getMethod(testName.getMethodName());
...
}
...
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)