Currently when running a maven build all my tests are run and a surefire-report is created as an XML log (called TEST-my.project.TestApp).
I have created my own custom annotation, @Trace(RQ = "requirement it tests") in order to link my tests to a certain requirement which it is verifying.
What I want is that when a test is run with Maven during a build, inside the XML Log that is generated in surefire-reports instead of:
<testcase time="0.113" classname="my.project.TestApp" name="FirstTest"/>
I should get:
<testcase time="0.113" classname="my.project.TestApp" name="FirstTest">
<traceability>requirement it tests</traceability>
</testcase>
My problem is:
How do I hook my annotation and implementation of the handling of the said annotation to the JUnit class runner used by Maven when it builds? Or how to hook it to the surefire plugin which creates the report?
Ok, I managed to do something which works pretty well for me:
First I do my custom annotation:
Then I do a listener:
Then I make my own Junit test runner in which I add my listener:
Lastly I add to the pom XML the following:
This will generate my own xml report at maven build in which I have a correlation between requirements and tests and which i can further use to generate a HTML report or anything really.