I have a test class that I’m trying to run from a main method with the folowing code :
Result r = org.junit.runner.JUnitCore.runClasses(TestReader.class);
when I examine the Result object I can see that 5 tests have been run but nothing is printed on the screen.
Should I do something else to get an output ?
There isn’t a very clean way of doing this, since it isn’t a common thing to do. You only need to print the output if you are creating a program that can be used to run tests on the command line, and JUnitCore itself does that.
All of the options involve using classes in an internal package.
If you want to print to something other than
System.out, you can create your own subclass oforg.junit.internal.JUnitSystemand use that instead ofRealSystemYou can also use
org.junit.internal.TextListener. SeerunMain(JUnitSystem system, String... args)in the JUnitCore source for an example.