2012-02-29 127 views
0
 
[email protected]:/home/dj/workspace/TestProject# ant test 
Buildfile: /home/dj/workspace/TestProject/build.xml 

test: 
    [junit] Testsuite: TestProject 
    [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec 
    [junit] 
    [junit]  Caused an ERROR 
    [junit] TestProject 
    [junit] java.lang.ClassNotFoundException: TestProject 
    [junit]  at java.net.URLClassLoader$1.run(URLClassLoader.java:202) 
    [junit]  at java.security.AccessController.doPrivileged(Native Method) 
    [junit]  at java.net.URLClassLoader.findClass(URLClassLoader.java:190) 
    [junit]  at java.lang.ClassLoader.loadClass(ClassLoader.java:306) 
    [junit]  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) 
    [junit]  at java.lang.ClassLoader.loadClass(ClassLoader.java:247) 
    [junit]  at java.lang.Class.forName0(Native Method) 
    [junit]  at java.lang.Class.forName(Class.java:169) 
    [junit] 

BUILD FAILED 
/home/dj/workspace/TestProject/build.xml:17: Test TestProject failed 

Total time: 0 seconds 
<project name="TestProject" basedir="." default="" > 
<property name="src" value="./src" /> 
<property name="lib" value="./lib" /> 
<property name="classes" value="./classes" /> 
<property name="ant.project.name" value="com.megacorp.projx.util" /> 

    <path id="test.classpath"> 
     <pathelement location="${classes}" /> 
     <pathelement location="usr/junit.jar" /> 
     <fileset dir="${lib}"> 
     <include name="**/*.jar"/> 
     </fileset> 
    </path> 

    <target name="test"> 
     <junit fork="yes" haltonfailure="yes"> 
     <test name="${ant.project.name}" /> 
     <formatter type="plain" usefile="false" /> 
     <classpath refid="test.classpath" /> 
     </junit> 
    </target> 

Ant生成錯誤:當我嘗試運行該錯誤會產生

回答

0

這是錯誤的:

<test name="${ant.project.name}" /> 

在這裏,你應該設置你想要的的JUnit類的名稱測試,而不是螞蟻項目的名稱。

例如:

<test name="myorg.MyTest" /> 

鏈接:
Documentation for junit task:看看實施例在底部

+0

但<測試名稱= 「$ {ant.project.name}」/>自動參考測試項目名稱。 – 2012-03-06 05:35:19

+0

@DilipJoshi但它必須提到一個java類,而不是螞蟻項目 – oers 2012-03-06 05:37:37

+0

謝謝它的作品..!你能告訴我如何改變主機名在螞蟻HTML報告我的意思是我主機作爲安卓代替Ubuntu的主機。 – 2012-03-06 06:03:37