【发布时间】:2017-04-23 15:57:32
【问题描述】:
下面是我的 Build.xml 文件。我正在尝试通过 Build.xml 执行我的 TestNG.xml,但我每次都收到以下错误。
[testng] 在类路径中找不到类:
在编译目标之前,以下文件工作正常。我猜在 exec 目标中编写的代码存在一些问题。
如果我尝试单独执行我的 TestNG.xml 文件,它工作得非常好。没有问题。但是当我从 Build.xml 执行我的 TestNG.xml 时,问题就来了。
我已尝试通过在 stackoverflow 上找到的多种方法解决此问题,例如:
- 清理项目
- 更新 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>
【问题讨论】:
标签: java xml apache ant testng