有什么方法可以将`org.testng.ITestResult``ITestNGMethod` 转换为`java.lang.reflect.Method`

Is there any way to convert from `org.testng.ITestResult` `ITestNGMethod` to `java.lang.reflect.Method`

想获取测试class为运行时每次执行的测试方法。我使用下面的代码

@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

你不想要 getConstructorOrMethod() 按照 the documentation 吗?然后 getMethod() 在返回的 ConstructorOrMethod 对象上会给你底层方法