繁体   English   中英

有什么办法可以将org.testng.ITestResult或ITestNGMethod转换为java.lang.reflect.Method。

[英]Is there any way to convert from `org.testng.ITestResult` `ITestNGMethod` to `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.ITestResult ITestNGMethod转换为java.lang.reflect.Method

您是否getConstructorOrMethod()按照文档 getConstructorOrMethod() 然后,返回的ConstructorOrMethod对象上的getMethod()将为您提供基础方法

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM