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!
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.