我使用TestNG
和Selenium
。在此,我使用@AfterMethod
和@Test
注释。如何获取方法名称?
在我用过的方法@AfterMethod
中,我需要的方法名称有@Test
。
对于前:
为@TEST
注释变量的方法名
@Test
public void testmethod() {
System.out.println("test");
}
@AfterMethod
public void aftermethod() {
String methodnameofTESTANnnoation=....?
System.out.println([email protected]);
}
在这里,我需要@Test
标注方法的名称即TestMethod的。
有与返回的值什么问题? make testmethod public String testmethod()并添加return(“testmethod”)例如然后尝试String methodnameofTESTANnation = testmethod(); – ReadyFreddy
@shmosel问题是关于testng的。对于testng检查了这个 - http://stackoverflow.com/questions/2952202/how-do-i-get-the-name-of-the-test-method-that-was-run-in-a-testng-拆卸 - 甲基无定向= 1&lq = 1 – Grasshopper
@草蜢良好的捕获。你的链接看起来像一个完美的副本。 – shmosel