我对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