2013-05-22 23 views
0

使用ant運行testng測試,但它不運行或顯示任何錯誤。即使消息(運行測試)也不會打印在控制檯中。這裏是build.xml。構建成功並且創建一個JAR。感謝任何幫助。testng任務不與螞蟻一起運行

<?xml version="1.0" encoding="UTF-8"?> 
<project name="BANC"> 

<property name="project.path" value="." /> 
<property name="src" value="${project.path}/src" /> 
<property name="bin" value="${project.path}/bin" /> 
<property name="testngxmldir" value="${project.path}/src/com/portico/regressionsuite" /> 
<property name="bancJarFile.path" value="./build/BANC.jar" /> 

<!-- Set class path libraries to be used for compilation --> 
<path id="class.path"> 
<pathelement location="lib" path="lib/activation.jar"/> 
<pathelement location="lib" path="lib/commons-lang-2.4.jar"/> 
<pathelement location="lib" path="lib/jxl.jar"/> 
<pathelement location="lib" path="lib/logging-selenium-1.2.jar"/> 
<pathelement location="lib" path="lib/mail.jar"/> 
<pathelement location="lib" path="lib/ojdbc14.jar"/> 
<pathelement location="lib" path="lib/poi-3.0.2-FINAL.jar"/> 
<pathelement location="lib" path="lib/reportng-1.1.1.jar"/> 
<pathelement location="lib" path="lib/saxon-8.7.jar"/> 
<pathelement location="lib" path="lib/selenium-grid-demo-1.0.7.jar"/> 
<pathelement location="lib" path="lib/selenium-grid-demo-standalone-1.0.7.jar"/> 
<pathelement location="lib" path="lib/selenium-grid-hub-1.0.7.jar"/> 
<pathelement location="lib" path="lib/selenium-grid-hub-standalone-1.0.7.jar"/> 
<pathelement location="lib" path="lib/selenium-grid-remote-control-1.0.7.jar"/> 
<pathelement location="lib" path="lib/selenium-grid-remote-control-standalone-1.0.7.jar"/> 
<pathelement location="lib" path="lib/selenium-grid-tools-1.0.7.jar"/> 
<pathelement location="lib" path="lib/selenium-grid-tools-standalone-1.0.7.jar"/> 
<pathelement location="lib" path="lib/selenium-server-1.0.3-standalone.jar"/> 
<pathelement location="lib" path="lib/velocity-1.7.jar"/> 
<pathelement location="lib" path="lib/jna-3.4.0.jar"/> 
<pathelement location="lib" path="lib/sikuli-script.jar"/> 
<pathelement location="lib" path="lib/testng-6.8.jar"/> 
<pathelement location="lib" path="${bin}"/> 
</path> 

<!-- Compile targets--> 
<target name="banc"> 
    <echo message="Compiling BANC Source..." /> 
    <mkdir dir="${bin}" /> 
    <javac classpathref="class.path" destdir="${bin}" encoding="UTF-8" optimize="off" 
    debug="on" failonerror="true" srcdir="${src}" /> 
    <jar destfile="${bancJarFile.path}" basedir="${bin}" /> 
</target> 

<taskdef name="testng" classname="org.testng.TestNGAntTask"> 
    <classpath> 
     <pathelement location="lib/testng-6.8.jar"/> 
    </classpath> 
</taskdef> 

<target name="runTest"> 
<echo message="Running Tests..." /> 
    <testng classpathref="class.path" outputDir="${project.path}/test-output" 
    sourcedir="${bin}" haltOnfailure="true"> 
     <xmlfileset dir="${testngxmldir}" includes="regressionsuite.xml"/> 
    </testng> 
</target> 

</project> 
+0

你如何運行螞蟻?該ant文件既沒有默認任務的根元素,也沒有任何任務之間的依賴關係。 – creinig

+0

這只是一個錯字(它現在被糾正)。我正在做一個樣本運行這就是爲什麼沒有包含任何依賴關係。我試過從eclipse和命令行運行ant,但結果相同。 – Akbar

回答

2

因爲看起來你不告訴螞蟻運行哪個目標 - 所以它只是選擇第一個目標。如果你用ant banc runTest運行它,它應該很好。

執行此操作的常用方法是定義一個空目標,該目標取決於<project>標記中默認設置的所有預期目標。此外,您的「runTest」目標應該依賴於「banc」,因爲運行測試需要項目已經預先建好。在這種情況下,您也可以簡單地執行一個ant runTest - ant將按照正確的順序自動運行所有依賴任務。

+0

謝謝。 「ant banc runTest」工作。大多數聯機文檔沒有提到如果任務之間沒有依賴關係,則需要指定任務。 – Akbar