I worked on a project in which testclasses are run via JunitCore.run(testClasses) not via Ant because I have to run the project even with no ANT framework (so no Testng for the same reason). But I still need to create html and xml reports same as JUNIT/ANT. How to generate them in my case?
Right now I found https://github.com/barrypitman/JUnitXmlFormatter/blob/master/src/main/java/barrypitman/junitXmlFormatter/AntXmlRunListener.java may be used to generate xml report. How do I generate html similar to junit-noframes.html? Are there existing methods to convert the TESTS-TestSuites.xml to junit-noframes.html and how? if not, how to generate the html? I do not even find the standard of the html format.
In fact I solved the problem myself in this way:
First I use https://code.google.com/p/reporting-junit-runner/source/browse/trunk/src/junitrunner/XmlWritingListener.java?spec=svn2&r=2
to create TESTS-*.xml
Then I write the following code myself to create TEST-SUITE.xml and junit-noframes.html. The idea is make use of API of ANT to create reports without really running test. so far the solution works for me.
Project project = new Project();
//a fake project feeding to ANT API so that latter not complain
project.setName("dummy");
project.init();
FileSet fs = new FileSet();
fs.setDir(new File(reportToDir));
fs.createInclude().setName("TEST-*.xml");
XMLResultAggregator aggregator = new XMLResultAggregator();
aggregator.setProject(project);
aggregator.addFileSet(fs);
aggregator.setTodir(new File(reportToDir));
//create TESTS-TestSuites.xml
AggregateTransformer transformer = aggregator.createReport();
transformer.setTodir(new File(reportToDir));
Format format = new Format();
format.setValue(AggregateTransformer.NOFRAMES);
transformer.setFormat(format);
//create junit-noframe.html
aggregator.execute();