Reputation: 45
I want to implement a custom reporter for TestNG xml test results. I currently use JUnitReportReporter. My result xml currently looks like this:
testcase name="testSearchForProductAndVerifyFirstFoundItem" time="55.516" classname="com.jpard.jaf.test.SearchForAnItemTests"
I simply want to replace testcase name with the Test Description as in @Test(description = "Test that first item in the results is the one searched for"). How can I do that in the simplest way possible. Many thanks!
Upvotes: 0
Views: 810
Reputation: 45
I did it simple extending JUnitReportReporter class and overriding getTestName method to show in xml report method name and description. The class looks like this:
public class CustomReporter extends JUnitReportReporter {
@Override
protected String getTestName(ITestResult tr) {
return tr.getMethod()
.getMethodName() + ": " + tr.getMethod()
.getDescription();
}
}
I hope it helps anyone looking for this issue.
Upvotes: 1
Reputation: 3263
I think you'll have to implement IMethodInterceptor
interface which will return a list of method instances , IMethodInstance
and then
from that list get all instances one by one and then
desc = instance.getMethod().getDescription();
method getDescription()
Have a look here
Upvotes: 0