troubleshooting Question

JUnit HTML Report With Ant And IntelliJ IDEA

Avatar of samblake
samblake asked on
JavaJava EE
5 Comments1 Solution1670 ViewsLast Modified:

I'm new to the whole Ant thing. In fact I'm new to JUnit too but I don't think that should be a problem. I'm wanted to created HTML reports with Ant as it is said here:

"   1.

      Ensure that Ant's optional.jar file is either in your CLASSPATH or exists in your $ANT_HOME/lib directory.

      Add an ANT property for the directory containing the HTML reports:
      <property name="test.reports" value="./reports" />

      Define the Ant task for running JUnit and generating reports:

<target name="test-html">
  <junit fork="yes" printsummary="no" haltonfailure="no">
    <batchtest fork="yes" todir="${test.reports}" >
      <fileset dir="${classes}">
        <include name="**/*Test.class" />
    <formatter type="xml" />
    <classpath refid="test.classpath" />

  <junitreport todir="${test.reports}">
    <fileset dir="${test.reports}">
      <include name="TEST-*.xml" />
    <report todir="${test.reports}" />


      Run the test:
      ant test-html"

I have added optional.jar from the IntelliJ IDEA\lib directory to the Additional Classpath List in the Build File Propertys. I have created a folder call "reports" in the same directory as the build.xml file and changed value="./reports" to value="reports".

I then copied in the code in step three. tot he build file and surrounded it by <project name="MyProject" default="test-html" basedir="."> and <\project> tags. This, however doesn't run (I am running it from the IntelliJ Ant Build thing). I have also added the tags:

<property name="src" value="src" />
<property name="lib" value="lib" />
<property name="classes" value="classes" />

Having never used Ant before I'm not sure what the problem is.  When I try to run this I get the error "Could not create class or type of type: junit" pointing to the "<junit fork="yes" printsummary="no" haltonfailure="no">" line.

If I add the target:

<target name="hello">
        <echo message="Hello"/>

that will run however.

Any help would be much appreciated. Thanks.


Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros