Junit测试不从Ant脚本部署

时间:2010-10-14 02:11:59

标签: ant junit

我有一个蚂蚁脚本,我正在尝试运行我的junit测试。它运行除了蚂蚁的junit部分之外的所有部分没有错误。任何人都知道为什么它没有达到我脚本的这一部分?

<?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>

1 个答案:

答案 0 :(得分:3)

没有目标正在调用“test”。

一种可能性是替换

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

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