TaT FreeformProjectJUnitResults



It is pretty straightforward to bind the output of a Freeform Project JUnit task to the NetBeans JUnit test results. However, there are a couple of minor tweaks that I find myself making and forgetting, so, the conclusion is that it is worth documenting the steps for future reference.

It should also be noted that the original version of this entry came from my blog entry at Freeform Project JUnit Results


Make sure the JUnit task is properly set up

The JUnit task needs to have an attribute showoutput="true" and has formatters that explicitly states that doesn't use a file, e.g.

  <formatter usefile="false" type="brief"/>
  <formatter type="xml"/>

Emphasis on not using a file : e.g. you can use an xml formatter and it would work; however, if you don't specify the usefile="false" attribute, everything goes to the file and NetBeans doesn't get a chance to capture the output and display the results in a nice JUnit test results tree. As a result, the best combination ends up being a combination of a xml formatter that outputs to a file, and a brief formatter that doesn't, e.g. :

<junit fork="yes" printsummary="withOutAndErr" showoutput="true" errorProperty="test.failed" 
          failureProperty="test.failed"     filtertrace="false">
    <formatter type="xml">
    <formatter usefile="false" type="brief" />
    <classpath refid="whatever-path-id" />     

Make sure the source path is properly set up

When you click on the failure in the JUnit results, you want NetBeans to take you to the right line in the source code: Image:netbeans_junit_beauty_TaT_FreeformProjectJUnitResults.png

In order to accomplish that, make sure that you properly set the output directory for your test cases in your NetBeans project with the UI or project.xml:

  • In the Project Properties UI

File:Project Properties : Output

  • In the nbproject/project.xml
<java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/2">\n ....
        <classpath mode="compile">${test.completion.classpath}</classpath>


Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo