Testng:在侦听器中获取调用的方法参数信息

Testng:在侦听器中获取调用的方法参数信息,testng,Testng,我需要在运行时在方法侦听器中获取有关方法调用的信息。通过数据提供程序传递给方法的参数值 这是我的测试课 @Listeners(MyListener.class) class MyTest{ @Test(dataProvider="myDataProvider") public void myTest(ITestContext context , SomeParam param){ // test something } } 这是我的听众 public c

我需要在运行时在方法侦听器中获取有关方法调用的信息。通过数据提供程序传递给方法的参数值

这是我的测试课

@Listeners(MyListener.class)
class MyTest{

   @Test(dataProvider="myDataProvider")
   public void myTest(ITestContext context , SomeParam param){
      // test something
   }    
}
这是我的听众

public class MyListener implements IInvokedMethodListener2{
  // other methods omitted

 @Override
 public void beforeInvocation(IInvokedMethod method, 
           ITestResult testResult,  ITestContext context) {

    // so i have access to the invoked method thru the "method"
    // argument.
    // I need to print the value of SomeParam that was 
    // passed to the method  
    // what do i do here to get access to the 
    // instance of SomeParam that was passed to the method ?

    SomeParam param = method.what().to().call();
    System.out.println(param);

}

参数存储在testResult中,而不是方法so
testResult。getParameters()
工作正常。

参数存储在testResult中,而不是方法so
testResult.getParameters()
工作正常。

在eclipse调试器中,当我查看IInvokedMethod参数时,我可以看到根据m_参数在中传递的参数,因此传递的“方法”实例确实包含它。。问题是如何访问它。在eclipse调试器中可能存在重复当我查看IInvokedMethod参数时,我可以看到根据m_参数在中传递的参数,因此传递的“方法”实例确实包含它。。问题是我如何访问它。可能重复