在我目前的项目中,我使用JUnit测试。 乳宁在我的本地PC我的Ant文件生成我的测试报告符合市场预期,但是当竹尝试运行我的测试中,它产生以下输出。
请告诉我我的错误?
SimplerTest.java
import static org.junit.Assert.*;
import org.junit.Test;
public class SimplerTest {
@Test
public void dummerTest()
{
assertTrue(true);
}
}
本地输出:
Buildfile: C:\Users\jussi\git\kingdom-builder-repository\build.xml
compile-test:
[javac] Compiling 1 source file to C:\Users\jussi\git\kingdom-builder-repository\bin
junit:
[junit] Running me.jussi.kingdombuilder.SimplerTest
[junit] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0,062 sec
main:
BUILD SUCCESSFUL
Total time: 1 second
服务器的输出:
compile-test:
[javac] Compiling 1 source file to /var/atlassian/application-data/bamboo/xml-data/build-dir/KB-KBP1-JOB1/bin
junit:
BUILD FAILED
/var/atlassian/application-data/bamboo/xml-data/build-dir/KB-KBP1-JOB1/build.xml:108: Using loader AntClassLoader[/opt/apache-ant-1.9.0/lib/ant-launcher.jar:/opt/ant/lib/ant.jar:/opt/ant/lib/ant-junit.jar:/opt/ant/lib/ant-junit4.jar:/var/atlassian/application-data/bamboo/xml-data/build-dir/KB-KBP1-JOB1/kingdom-builder/libs/junit-4.10.jar:/var/atlassian/application-data/bamboo/xml-data/build-dir/KB-KBP1-JOB1/bin]
on class org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter: java.lang.NoClassDefFoundError: junit/framework/TestListener
build.xml文件
<?xml version="1.0"?>
<project name="KingdomBuild" default="main" basedir=".">
<!-- Sets variables which can later be used. -->
<!-- The value of a property is accessed via ${} -->
<property name="test.src.dir" location="kingdom-builder/test" />
<property name="build.dir" location="bin" />
<property name="test.report.dir" location="testreport" />
<!-- Define the classpath which includes the junit.jar and the classes after compiling-->
<path id="junit.class.path">
<pathelement location="kingdom-builder/libs/junit-4.10.jar" />
<pathelement location="${build.dir}" />
</path>
<!-- Compiles the java code (including the usage of library for JUnit -->
<target name="compile-test">
<javac srcdir="${test.src.dir}" destdir="${build.dir}" includeantruntime="false">
<classpath refid="junit.class.path" />
</javac>
</target>
<!-- Run the JUnit Tests -->
<!-- Output is XML, could also be plain-->
<target name="junit" depends="compile-test">
<junit printsummary="on" fork="true" haltonfailure="true">
<classpath refid="junit.class.path" />
<formatter type="xml" />
<batchtest todir="${test.report.dir}">
<fileset dir="${build.dir}">
<include name="**/*Test*.class" />
</fileset>
</batchtest>
</junit>
</target>
<target name="main" depends="junit">
<description>Main target</description>
</target>
</project>
蚂蚁-v输出:
http://nopaste.info/1abdd27a8e.html