2013-11-20 22 views
0

硒的webdriver + TestNG的+ ANT 我有一个错误运行-ant的runTest C:\ seleniumtests>蚂蚁的runTest 构建文件:C:\ seleniumtests \的build.xml[的taskdef]无法从资源testngtasks加载定义

compileTests: [罐子]大厦的jar:C:\ seleniumtests \ AntruTests.jar

的runTest: [的taskdef]无法加载从资源testngtasks定义。它找不到e 。

构建失败 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> 

我做错了吗? 谢谢!

+0

可能重复http://stackoverflow.com/questions/7263301/testng-taskdef-definition-in-ant-使用Maven的依赖关系) –

+0

可能dublicate,但http://stackoverflow.com/a/10896353/3012546 does not帮助,同样的错误( – user3012546

+0

错误信息表明无法找到testng的任务jar。检查两个taskdef和jar的位置好的方法是在调试模式下运行ANT。 –

回答

0
<taskdef resource="testngtasks" classpath="${test.classpath}"/> 

感谢您的帮助!

1
<taskdef resource="testngtasks" classpath="${lib.dir}/testng-6.8.7.jar"/> 

Ant在设置$ {lib.dir}之前处理[taskdef]。您需要设置绝对路径一样,

<taskdef resource="testngtasks" classpath="/usr/local/lib/testng-6.8.7.jar"/> 
[Ant中使用Maven依赖TestNG中的taskdef定义](的