JUnitテストをAntビルドに自動化しています。しかし、私の単純なテストは、IDEとコマンドラインから実行した場合にのみ成功しますが、Antの<junit>
タスクでは失敗します。JUnitテストは `<junit>`タスクのAntでは失敗しますが、 `<exec>`と合格しますか?
clean:
compile_tests:
[javac] Compiling 2 source files to C:\MY_TEMP
junit_exec:
[exec] JUnit version 4.10
[exec] .
[exec] Time: 0.004
[exec]
[exec] OK (1 test)
[exec]
BUILD SUCCESSFUL
Total time: 1 second
が、私は<junit>
タスクを使用する場合::私は(私は技術的にはAntの<exec>
タスクを使用しています)コマンドラインから実行すると結果がMY_TEMP
の
Buildfile: C:\MY_TEMP\build.xml
clean:
compile_tests:
[javac] Compiling 2 source files to C:\MY_TEMP
junit_ant:
[echo] junit_ant started
[junit] Test SimpleTest FAILED
BUILD SUCCESSFUL
Total time: 0 seconds
内容がjunit-4.10.jar
をしています、 SimpleTest.java
およびbuild.xml
である。
Ant junit task documentationのように、%ANT_HOME%\lib
フォルダにjunit-4.10.jar
をコピーしました。すでにant-junit.jar
とant-junit4.jar
の両方がありました。
Javaのバージョンは1.6.0_26です。
私のテストは次のとおりです。
// YES, this is the default package
import org.junit.*;
public class SimpleTest {
@Test
public void mySimpleTest(){
Assert.assertEquals( 2, 1 + 1 );
}
}
そして、私のAntファイル(build.xmlの)、次のとおりです。
<?xml version="1.0"?>
<project name="regression_tests" basedir=".">
<target name="clean">
<delete>
<fileset dir="." includes="*.class" />
</delete>
</target>
<target name="compile_tests" depends="clean">
<javac srcdir="." destdir="." source="1.6" target="1.6" includeantruntime="false" >
<classpath>
<pathelement location="./junit-4.10.jar" />
</classpath>
</javac>
</target>
<target name="junit_ant" depends="compile_tests" >
<echo message="junit_ant started" />
<junit>
<test name="SimpleTest" />
</junit>
</target>
<target name="junit_exec" depends="compile_tests">
<exec executable="java" dir="." >
<arg value="-classpath" />
<arg value=".;junit-4.10.jar" />
<arg value="org.junit.runner.JUnitCore" />
<arg value="SimpleTest" />
</exec>
</target>
</project>
テストの失敗は何ですか? –
どうすればそれを見つけることができますか? Antに与えられた '-v'オプションを指定しても、失敗に関する何も表示されません。テスト自体が失敗しないと判断して、私は構成的なものを見逃しているはずです。 – ArtB
テストレポートをご覧ください。 –