Junit Ant集成问题



我有一个单独的junit测试用例,它与ant脚本集成在一起。单独的junit运行良好,测试用例通过。当它与蚂蚁集成一起执行时,它会失败。

测试用例和ant脚本如下,

import org.junit.Test;
public class SimpleTest 
{
    @Test
    public void testHello()
    {
        System.out.println("Hello");
    }

}

蚂蚁的脚本是

<property file="build.properties" />
<path id="libirary">
    <fileset dir="${lib}">
        <include name="**.*jar" />
    </fileset>
</path>


<target name="clean">
    <delete dir="${build.classes.dir}" />
    <delete dir="${build.dir}" />
    <delete dir="${dist.dir}" />
</target>
<target name="init" depends="clean">
    <mkdir dir="${build.classes.dir}" />
    <mkdir dir="${dist.dir}" />
</target>

<target name="compile" depends="init">
    <javac encoding="ISO-8859-1" destdir="${build.classes.dir}" srcdir="${src.dir}">
        <classpath>
            <path refid="libirary" />
        </classpath>
    </javac>
</target>
<target name="jar" depends="compile">
    <jar destfile="${dist.dir}/${jar.filename}.jar">
        <fileset dir="${build.classes.dir}" />
        <zipfileset dir="${lib}" includes="**/*.jar" />
        <manifest>
            <attribute name="Main-Class" value="${main.file.name}" />
        </manifest>
    </jar>
</target>

<target name="junit" depends="compile">
    <junit   printsummary="yes" description="true" filtertrace="yes" >
        <classpath path="${lib}">
            <path refid="libirary" />
        </classpath>
        <test name="SimpleTest">
        </test>
    </junit>
</target>

输出为

Buildfile: D:WorkspacesTrunkForCheckIn-31-05-2013PGbuild.xml
clean:
   [delete] Deleting directory 
   [delete] Deleting directory 
   [delete] Deleting directory 
init:
    [mkdir] Created dir: 
    [mkdir] Created dir: 
compile:
    [javac]  warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
    [javac] Compiling 57 source files to 
    [javac] Note: Some input files use unchecked or unsafe operations.
    [javac] Note: Recompile with -Xlint:unchecked for details.
junit:
    [junit] Running SimpleTest
    [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
    [junit] Test com.bosch.in.stepage.pg.SimpleTest FAILED
BUILD SUCCESSFUL
Total time: 1 second

尝试添加一个普通格式化程序:

<target name="junit" depends="compile">
    <junit   printsummary="yes" description="true" filtertrace="yes" >
    <formatter type="plain" usefile="false" />
        <classpath path="${lib}">
            <path refid="libirary" />
        </classpath>
        <test name="SimpleTest">
        </test>
    </junit>
</target>

相关内容

  • 没有找到相关文章

最新更新