首页 文章

[taskdef]无法从资源testngtasks加载定义

提问于
浏览
0

Selenium Webdriver testNG ANT运行时运行错误C:\ seleniumtests> ant runtest Buildfile:C:\ seleniumtests \ build.xml

compileTests:[jar]构建jar:C:\ seleniumtests \ AntruTests.jar

runtest:[taskdef]无法从资源testngtasks加载定义 . 它无法找到 .

BUILD FAILED 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>

我做错了什么?谢谢!

2 回答

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

    Ant在设置$ 之前处理[taskdef] . 你需要设置绝对路径,如,

    <taskdef resource="testngtasks" classpath="/usr/local/lib/testng-6.8.7.jar"/>
    
  • 1
    <taskdef resource="testngtasks" classpath="${test.classpath}"/>
    

    感谢帮助!

相关问题