有没有办法从`org.testng.ITestResult``ITestNGMethod`转换为`java.lang.reflect.Method`

sta*_*low 2 java testng

我想获得每次运行测试类时执行的测试方法.我使用以下代码

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

有没有办法转换org.testng.ITestResult ITestNGMethodjava.lang.reflect.Method

Bri*_*new 5

难道你不希望getConstructorOrMethod()按照文件?然后getMethod()在返回的ConstructorOrMethod对象上将为您提供基础方法