JUnit 4 result for XML conversion

I am trying to write code to generate XML output from a Junit Result object using the standard schema for Junit reports.

I run my tests using Junit 4, so I use an instance of JunitCore to run my tests. Therefore, in my case, it makes no sense to duplicate execution using an instance of JunitTask.

I am moving on to the testRunfinished (Result) method available in Junit4. I want to write the transformation logic here so that it generates XML, which can then be viewed using standard XSLT.

One way would be to write a transformer that creates a document object, and then programmatically add nodes and, therefore, create XML. But that would complicate the structure of the report.

All classes opened with Ant seem to work with Junit3 and do not seem to separate the problems from running tests and reports, so they are forced to execute (XMLResultAggregator).

  • Is there a standard way to do this? Library open by Ant or Junit?
  • Is there an alternative approach (Ant is not an option for me)?

Thanks in advance.

+3
source share
1 answer

Why not create standalone HTML with CSS in header reports? Or even plain text txt.

I created my XML reports using a template that I copied and then populated the fields using the Java xml framework.

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult; 
0
source

All Articles