Ashish,
What you are asking for is only available partially in TestNG.
TestNG has an attribute on the "@Test" annotation using which you can pass in any amount of custom attributes (You don't need any custom annotation from your own side)
Here's a sample
import org.testng.annotations.CustomAttribute;
import org.testng.annotations.Test;
public class SampleTestClass {
@Test(attributes = {
@CustomAttribute(name = "name", values = "dragon-warrior"),
@CustomAttribute(name = "skill-set", values = {"kung-fu", "eating-dumplings"})
})
public void sampleTestMethod() {
System.err.println("Hello world test case ran");
}
}
AFAIK, TestNG doesn't read these attributes in its own default reports (That's strange. We should have honoured them. Maybe we can do that in the upcoming version of TestNG as part of this new issue that I have just now created
https://github.com/cbeust/testng/issues/2725)
So for you to be able to see them in the JUnit reports, you would need to build your own customisation around it by extending one of the following
org.testng.reporters.EmailableReporter2 - This is what builds the emailable-report
org.testng.reporters.JUnitReportReporter - This is what generates the junit reports
I don't know if it would make sense for you to add these attributes into the JUnit reports, because I think the JUnit reports follow a schema and if the schema doesn't have a provision for this, there's a very good chance that all tools (Jenkins for e.g., ) which use a schema to parse JUnit reports would ignore rendering these custom attributes.
Hope that helps!
Thanks & Regards
Krishnan Mahadevan
"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/