Using maven to create junit xml reports of jar

2019-06-05 05:30发布

问题:

I have inherited a codebase whereby we have a maven project of component tests that use junit as the framework that runs the tests.

Everything runs OK, but the problem is that these tests must be compiled into a jar-with-dependencies so that they can be run on a standalone computer with very limited outwards connectivity (e.g does not have access to maven central).

I have managed to create a runnable jar with dependencies which I can run using junit.jar and the command line like so:

java -cp jar-with-dependencies.jar:junit.jar junit.jar org.junit.runner.JUnitCore com.testsuite.AllTests

This works but the problem is that I also need to output the junit results into XML, like maven's surefire plugin does.

My question is, can I run this jar-with-dependencies using maven such that it creates the junit xml reports?

I can successfully run the tests using exec-maven-plugin which essentially runs the previously stated command