私はAntを初めて使用し、昨日いくつかの助けを借りて簡単なbuild.xmlを作成しました。しかし、実行した ant -verbose の出力を見ると、多くの JUnit テストを処理しなければならないクラスが適切に呼び出されていないように見えます。
<project name="JUnit_tests" default="run" basedir=".">
<!-- Define variable properties -->
<property name="src" value="${basedir}"/>
<property name="junit" value="org.junit.runner.JUnitCore"/>
<!--<property name="junit" value="org.junit.runner.JUnitCore"/>-->
<!-- Appends all jars in the current directory to the classpath -->
<path id="compile.classpath">
<fileset dir="./">
<include name="*.jar"/>
</fileset>
</path>
<!-- Compiles all code in the current directory and append to the classpath -->
<target name="compile">
<javac destdir="${src}" srcdir="${src}">
<classpath refid="compile.classpath"/>
</javac>
</target>
<!-- Runs the Test code with junit argument as long as compile was run previously -->
<target name="run" depends="compile">
<java classname="Tests" fork="true">
<arg value="${junit}"/>
</java>
</target>
私の JUnit テストは Tests クラスにあり、クラスを実行する必要があります
java org.junit.runner.JUnitCore Tests
ただし、次の出力に基づいて、次のように呼び出されていると思います
java Tests org.junit.runner.JUnitCore
Ant - 詳細出力:
run:
[java] Executing '/usr/lib/jvm/java-6-sun-1.6.0.26/jre/bin/java' with arguments:
[java] 'Tests'
[java] 'org.junit.runner.JUnitCore'
[java]
[java] The ' characters around the executable and arguments are
[java] not part of the command.
[java] Exception in thread "main" java.lang.NoSuchMethodError: main
[java] Java Result: 1
何か案は?私は調査を行ってきましたが、引数の順序、特にJava呼び出しについてはあまり見つけられませんでした。ありがとう!