从 Build.xml(ANT) 执行 TestNG.xml 文件
Execute TestNG.xml file from Build.xml(ANT)
下面是我的 Build.xml 文件。我试图通过 Build.xml 执行我的 TestNG.xml 但我每次都收到以下错误。
[testng] 在 class 路径中找不到 class:
以下文件在编译目标之前工作正常。我猜 exec target.
中编写的代码存在一些问题
如果我尝试单独执行我的 TestNG.xml 文件,它工作得很好。没有问题。但是当我从 Build.xml.
执行我的 TestNG.xml 时,问题就来了
我尝试通过在 Whosebug 上找到的多种方法解决问题,例如:
- 正在清理项目
- 正在更新 TestNG 库
但没有成功。
谁能帮我解决这个问题?
<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 中设置的 class 路径中。以下是正确的 class 路径。
<path id="classpath">
<pathelement location="${bin}" />
<fileset dir="${lib}">
<include name="**/*.jar" />
</fileset>
</path>
${bin} 是编译 .java 文件后 .class 文件所在的目录。
下面是我的 Build.xml 文件。我试图通过 Build.xml 执行我的 TestNG.xml 但我每次都收到以下错误。
[testng] 在 class 路径中找不到 class:
以下文件在编译目标之前工作正常。我猜 exec target.
中编写的代码存在一些问题如果我尝试单独执行我的 TestNG.xml 文件,它工作得很好。没有问题。但是当我从 Build.xml.
执行我的 TestNG.xml 时,问题就来了我尝试通过在 Whosebug 上找到的多种方法解决问题,例如:
- 正在清理项目
- 正在更新 TestNG 库 但没有成功。
谁能帮我解决这个问题?
<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 中设置的 class 路径中。以下是正确的 class 路径。
<path id="classpath">
<pathelement location="${bin}" />
<fileset dir="${lib}">
<include name="**/*.jar" />
</fileset>
</path>
${bin} 是编译 .java 文件后 .class 文件所在的目录。