我對Ant很陌生,昨天寫了一個簡單的build.xml。然而,在查看運行ant -verbose的輸出後,看起來好像一個類我不得不處理許多JUnit測試。Ant任務參數的順序
<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測試是在測試類,我需要與
java org.junit.runner.JUnitCore Tests
但是基於以下的輸出,我相信它被稱爲運行類作爲
java Tests org.junit.runner.JUnitCore
Ant -verbose輸出:
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調用。謝謝!
考慮使用http://ant.apache.org/manual/Tasks/junit.html – Vadzim