【发布时间】:2013-11-20 10:08:22
【问题描述】:
Selenium Webdriver+testNG+ANT 我在运行 -ant runtest 时出错 C:\seleniumtests>蚂蚁运行测试 构建文件:C:\seleniumtests\build.xml
编译测试: [jar] 构建jar:C:\seleniumtests\AntruTests.jar
运行测试: [taskdef] 无法从资源 testngtasks 加载定义。它不能 b 找到了。
构建失败 C:\seleniumtests\build.xml:38: 问题:未能创建任务或键入 testng 原因:名称未定义。 行动:检查拼写。 行动:检查是否已声明任何自定义任务/类型。 行动:检查任何 / 声明已经发生。
总时间:1秒
build.xml:
<?xml version="1.0" encoding="iso-8859-1"?>
<project name="AntruTests">
<!-- Properties storage -->
<property file="build.properties"/>
<!-- Project's folders locations -->
<property name="project.path" value="." />
<!-- Set class path libraries to be used for compilation -->
<path id="class.path">
<pathelement location="lib" path="lib/selenium-java-2.37.0.jar"/>
<pathelement location="lib" path="lib/selenium-server-standalone-2.37.0.jar"/>
</path>
<!-- Title for ReportNG -->
<property name="report.title" value="Automated tests report for AntruTests"/>
<!-- Compile classes -->
<target name="compileTests">
<javac classpathref="class.path" includeantruntime="false" destdir="C:\seleniumtests" encoding="UTF-8" optimize="off"
debug="on" failonerror="true" srcdir="C:\seleniumtests" />
<jar destfile="AntruTests.jar" basedir="C:\seleniumtests" />
</target>
<target name="prepareForRunning" depends="compileTests">
<delete dir="${tests.results.folder}" />
<mkdir dir="${tests.results.folder}" />
</target>
<target name="runtest" depends="compileTests" description="Runtests">
<taskdef resource="testngtasks" classpath="${lib.dir}/testng-6.8.7.jar"/>
<testng outputdir="${testng.output.dir}" classpathref="classes">
<xmlfileset dir="${lib.dir}" includes="testng.xml"/>
</testng>
</target>
</project>
我做错了什么? 谢谢!
【问题讨论】:
-
可能是重复的,但stackoverflow.com/a/10896353/3012546 没有帮助,同样的错误(
-
错误提示找不到testng的任务jar。检查 jar 的 taskdef 和位置。检查的好方法是在调试模式下运行 ANT。