4

I need to use JUnitCore to run unit tests from a standalone jar test tool. I have added the surefire jars as dependencies and there I found the class org.apache.maven.surefire.junitcore.JUnitCoreRunListener. In this github this is a sample of its usage.

My intention is to get the xml report that would result from running maven without maven at runtime.

RunListener reporter = new JUnitCoreRunListener( new MockReporter(), new HashMap<String, TestSet>() );
JUnitCore jc = new JUnitCore();
jc.addListener( reporter );
Result r = jc.run( new Computer(), AppTest.class);
jc.removeListener( reporter );
System.out.println( r );

This is not working. What is the correct approach to get the XML output from that reporter?

Camilo Crespo
  • 615
  • 5
  • 15

0 Answers0