我有一个单独的 junit 测试用例,它与 ant 脚本集成在一起。单独的junit工作正常,测试用例通过。当它与 ant 集成一起执行时,它会失败。
测试用例和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:\Workspaces\TrunkForCheckIn-31-05-2013\PG\build.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