The TestNG tool creates an XML file in a format compatible with the JUnit Sensor. Thus, you can use the JUnit Sensor without change to send the results of TestNG testing to Hackystat.
TestNG is a framework similar to JUnit for simplifying the construction and invocation of unit tests in Java.
Using the JUnit sensor with TestNG requires Java 1.5.0 or later, Ant 1.6.5 or later, and TestNG 5.4 or later.
Download and install TestNG from its home page.
Follow the instructions in Chapter 2, Client-side configuration: Tool sensor installation to set your Hackystat host and user key.
TestNG produces XML files that can be processed by the JUnit Sensor. In the HackyInstaller main window, select the JUnit sensor and press "Configure Selected Sensor". Figure 26.37, “ JUnit sensor installer configuration window ” shows what the configuration window should look like after the path to Ant is set, the sensor is enabled, and the "Install" button has been pressed to install the sensor.
This sensor supports the following properties and paths:
Enable JUnit Sensor: This property controls whether the sensor is active or not. If not checked, the sensor will not collect or send data even if installed.
Ant home directory: This path specifies the top-level directory for Ant. The JUnit sensor requires the placement of a sensor executable into Ant's lib/ directory.
Define a target in your build.xml file to invoke TestNG and write out its results in XML format. The target should then invoke the JUnit sensor to send the results to Hackystat. Example 26.72, “An example TestNG target” illustrates one possible definition of such a target.
Example 26.72. An example TestNG target
<target name="testing" depends="compile"
description="Run TestNG tests.">
<property name="test.dir" location="${build.dir}/testng"/>
<mkdir dir="${test.dir}"/>
<!-- Run the tests. -->
<taskdef resource="testngtasks" classpath="testng.jar">
<testng outputdir="${test.dir}">
<fileset dir="${src.dir}" includes="testng.xml">
</testng>
<!-- Send the results to Hackystat -->
<taskdef name="hacky-junit" classname="org.hackystat.sensor.junit.JUnitSensor" />
<hacky-junit verbose="on" sourcePath="${src.dir}">
<fileset dir="${test.dir}">
<include name="*.xml"/>
<exclude name="testng-failed.xml"/>
</fileset>
</hacky-junit>
</target>
Please refer to the installation verification instructions for the JUnit sensor, located at Section 26.21, “JUnit”.
Please refer to the installation troubleshooting instructions for the JUnit sensor, located at Section 26.21, “JUnit”.
If none of the above troubleshooting activities solves your problem, then you should send an email to your Hackystat Administrator to request help. Please include in your email the following information:
The output from 'java -version'.
The output from 'java -jar sensorshell.jar -verify'.
The contents of your sensor.properties file.
The contents of the junit.0.log file.
A description of the problem you are having.