tags:

views:

15

answers:

1

I have an ant script that I am trying to run my junit test from. It runs all but the junit portion of the ant with no errors. Anyone know why it's not hitting this portion of my script?

<?xml version="1.0"?>

<property file="build.properties" />
<property name="test.class.name" value="edu.psu.ist.probability.TestProbability" />

<path id="test.classpath">
  <pathelement location="${classes}" />
  <pathelement location="/lib/junit.jar" />
  <fileset dir="${lib}">
    <include name="**/*.jar"/>
  </fileset>
</path>

<taskdef resource="checkstyletask.properties" classpath="${checkstyle}" />
<taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask">
    <classpath>
        <pathelement path="${findbugs.jar}" />
    </classpath>
</taskdef>

<!-- 
    Encapsulates the process of starting up program. 
-->
<target name="run" depends="build">
    <echo>-----------RUN-----------</echo>
    <java classname="${main}" fork="true">
        <!-- fork needed for running on OS X -->
        <classpath>
            <pathelement location="${jar}" />
            <fileset dir="lib">
                <include name="**/*.jar" />
            </fileset>
        </classpath>
    </java>
</target>

<!-- 
    Encapsulates the process of packaging (jarring) program. 
-->
<target name="build" depends="document">
    <echo>---------BUILD--------</echo>
    <jar destfile="${jar}" basedir="${classes}" />
</target>

<!-- 
    Encapsulates the process of generating javadoc for program. 
-->
<target name="document" depends="findbugs">
    <echo>-------DOC--------</echo>
    <javadoc sourcepath="${src}" defaultexcludes="yes" destdir="${docs}" executable="C:\Program Files (x86)\Java\jdk1.6.0_20\bin\javadoc.exe" author="true" version="true" use="true" windowtitle="Decisions API">
    </javadoc>
</target>

<!-- 
    Encapsulates the process of executing findbugs against program. 
-->
<target name="findbugs" depends="style">
    <echo>----------FINDBUGS----------</echo>
    <findbugs home="${findbugs}" output="html" outputFile="${findbugs.output}" failOnError="true" stylesheet="fancy.xsl">
        <auxClasspath>
            <fileset dir="${lib}">
                <include name="**/*.jar" />
            </fileset>
        </auxClasspath>
        <sourcePath path="${src}"/>
        <class location="${classes}" />
    </findbugs>
</target>

<!-- 
    Encapsulates the process of style-checking program. 
-->
<target name="style" depends="compile">
    <echo>---STYLE---</echo>
    <checkstyle config="${checkstyleconfig}" classpath="${classes}">
        <fileset dir="${src}" includes="**/*.java" 
            excludes="**/DecisionsProgram.java, **/*Test.java" />
    </checkstyle>
</target>

<!-- 
    Encapsulates the process of compiling program. 
-->
<target name="compile" depends="clean">
    <echo>------------COMPILE--------</echo>
    <javac destdir="${classes}">
        <src path="${src}" />
        <classpath>
            <fileset dir="lib">
                <include name="**/*.jar" />
            </fileset>
        </classpath>
    </javac>
</target>

<!-- 
    Encapsulates the process of cleaning up program directory structure. 
-->
<target name="clean">
    <!-- make sure dirs exist first, to prevent error -->
    <mkdir dir="${classes}" />
    <mkdir dir="${dist}" />
    <mkdir dir="${docs}" />
    <mkdir dir="${reports}" />
    <!-- now delete them -->
    <delete dir="${classes}" />
    <delete dir="${dist}" />
    <delete dir="${docs}" />
    <delete dir="${reports}" />
    <!-- now recreate them so they can be used -->
    <mkdir dir="${classes}" />
    <mkdir dir="${dist}" />
    <mkdir dir="${docs}" />
    <mkdir dir="${reports}" />
</target>
<target name="test" depends="compile">
    <echo>-------JUNIT----------</echo>
  <junit fork="yes" haltonfailure="yes">
    <test name="${test.class.name}" />
    <formatter type="plain" usefile="false" />
    <classpath refid="test.classpath" />
  </junit>
</target>

+3  A: 

There is no target which is invoking "test".

One possibility is to replace

<target name="style" depends="compile">

with

<target name="style" depends="test">
Raghuram
You're absolutely right! I figured this out last night. Thanks!
taraloca