2016-04-21 76 views
1

我想获得每次运行测试类时执行的测试方法。我用下面的代码有没有什么办法可以从`org.testng.ITestResult`` ITestNGMethod`转换为`java.lang.reflect.Method`

@AfterMethod 
public void logout(ITestResult result){ 
    Method method=result.getMethod(); //compliation error- Type mismatch: cannot convert from ITestNGMethod to Method 
readAnnotation(method); 
} 

有没有办法从org.testng.ITestResultITestNGMethod转换为java.lang.reflect.Method

回答

4

你不想getConstructorOrMethod()the documentation?然后getMethod()上返回ConstructorOrMethod对象会给你的基本方法

相关问题