[英]Is there any way to convert from `org.testng.ITestResult` `ITestNGMethod` to `java.lang.reflect.Method`
I want to get the test method that was executed each time when the test class is run. 我想获取每次运行测试类时执行的测试方法。 I use the following code 我使用以下代码
@AfterMethod
public void logout(ITestResult result){
Method method=result.getMethod(); //compliation error- Type mismatch: cannot convert from ITestNGMethod to Method
readAnnotation(method);
}
Is there any way to convert from org.testng.ITestResult
ITestNGMethod
to java.lang.reflect.Method
有什么办法可以将org.testng.ITestResult
ITestNGMethod
转换为java.lang.reflect.Method
Don't you want getConstructorOrMethod()
as per the documentation ? 您是否getConstructorOrMethod()
按照文档 getConstructorOrMethod()
? Then getMethod()
on the returned ConstructorOrMethod
object will give you the underlying method 然后,返回的ConstructorOrMethod
对象上的getMethod()
将为您提供基础方法
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.