Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The JUnit library does not have any XML output options. To achieve such a thing, you'll need to write your own <a href="http://kentbeck.github.com/junit/javadoc/latest/org/junit/runner/notification/RunListener.html" rel="nofollow noreferrer">RunListener</a>, which listens for the output and will in your case write the XML file.</p> <p>However, to get the XML file in the correct format so that it can be read by CI system, I think it would be far easier to just use ant, either via the command line using a build.xml (<a href="https://ant.apache.org/manual/Tasks/junitreport.html" rel="nofollow noreferrer">JUnitReport</a>), or using the java api: <a href="https://stackoverflow.com/questions/4085002/how-can-i-use-apache-ant-programmatically">How can i use Apache ANT Programmatically</a>.</p> <p>EDIT: Initially, we had four options:</p> <ol> <li>Use ant from the command line</li> <li>Use ant programmatically (using the Java API)</li> <li>Use the XMLJUnitResultFormatter directly with JUnitCore</li> <li>Create a custom RunListener which produces the correct XML output.</li> </ol> <p>Given the restrictions added by the OP, we can't use ant from the command line, which eliminates 1.</p> <p>After looking more closely at the Ant JUnit task, it seems to be impossible to use this with JUnitCore (adding a TestListener), because ant uses the name of the test class directly, so you can't do a bridge class. From <a href="http://svn.apache.org/repos/asf/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFormatter.java" rel="nofollow noreferrer">XMLJUnitResultFormatter.java</a></p> <pre><code>private void formatError(String type, Test test, Throwable t) { ... nested.setAttribute(ATTR_TYPE, t.getClass().getName()); String strace = JUnitTestRunner.getFilteredTrace(t); Text trace = doc.createTextNode(strace); nested.appendChild(trace); } </code></pre> <p>This eliminates 3.</p> <p>Invoke Ant programmatically, via the Java API. I can't find any recent documentation on this. This seems to be hard.</p> <p>So, finally, I would do 4, a custom RunListener, using the code from XMLJUnitResultFormatter as a base. And then, I'd publish it on github.com, so this question could be answered properly :-)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload