[英]Execute TestNG.xml file from Build.xml(ANT)
以下是我的Build.xml文件。 我正在嘗試通過Build.xml執行我的TestNG.xml,但是每次都會收到以下錯誤。
[testng]在類路徑中找不到類:
下面的文件可以正常工作,直到編譯目標為止。 我想在exec target中編寫的代碼存在一些問題。
如果我嘗試單獨執行TestNG.xml文件,則可以正常運行。 沒有問題。 但是問題出在我從Build.xml執行我的TestNG.xml時。
我已嘗試通過在stackoverflow上找到的許多方法來解決此問題,例如:
有人可以幫我嗎?
<property name="lib" value="./lib" />
<property name="bin" value="./bin" />
<path id="Sample Ant build.classpath">
<pathelement location="${output}" />
<fileset dir="${lib}">
<include name="**/*.jar" />
</fileset>
</path>
<target name="init">
<delete dir="${bin}">
</delete>
<mkdir dir="${bin}" />
</target>
<target name="compile" depends="init">
<javac srcdir="${src}"
destdir="${bin}"
includeantruntime="false"
debug="true">
<classpath refid="Sample Ant build.classpath"/>
</javac>
</target>
<!-- Runs the file and generates Reportng report for TestNG-->
<taskdef name="testng" classname="org.testng.TestNGAntTask" classpathref="Sample Ant build.classpath" />
<target name="exec" depends="compile">
<mkdir dir="${testng_report_dir}" />
<testng outputdir="${testng_report_dir}" classpathref="Sample Ant build.classpath" useDefaultListeners="true">
<xmlfileset dir="${basedir}" includes="Testng.xml" />
</testng>
</target>
問題出在我在build.xml中設置的類路徑中。 下面是正確的類路徑。
<path id="classpath">
<pathelement location="${bin}" />
<fileset dir="${lib}">
<include name="**/*.jar" />
</fileset>
</path>
$ {bin}是.java文件編譯后的.class文件所在的目錄。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.