How to get a variable value from a test method wit

2019-05-26 22:41发布

I'm using TestNG to run automation tests. I also implemented TestNG Listener to save the test results in a certain format.

For some specific scenario I need to do the following: When a test runs, a value is assigned to a variable (local method variable). I need to pass the value of the variable to the TestNG Listener class I implemented. There are various methods (ontestStart, onTestFinish, onTestSuccess/Failure/Skipped), but I cannot figure out how to get the variable at run time. And I didn't find it in TestNG documentation.

Can anyone please help? Or share his/her experience with a similar issue.

Thanks!

1条回答
虎瘦雄心在
2楼-- · 2019-05-26 22:42

You can try by listening to the method invocations and set values into the [ITestResult](http://testng.org/javadocs/org/testng/IAttributes.html#setAttribute(java.lang.String, java.lang.Object)). Then you'll find the values from ITestResult into your custom reporter.

查看更多
登录 后发表回答