taskdef类PackageName.找不到ClassName



我正在尝试运行用Java + Selenium + TestNG + Ant构建的Selenium测试。但是,当我运行build.xml时,抛出以下错误-

BUILD FAILED
G:WorkspaceAntProjectbuild.xml:14: taskdef class AntPackage.AntTest cannot be found
 using the classloader AntClassLoader[G:WorkspaceAntProjectlibstestng-6.8.jar]
Total time: 645 milliseconds

以下是build.xml -

<project basedir="." default="runTest" name="Ant file for TestNG">
<property name="src" location="src"/>
<property name="bin" location="bin"/>
<property name="libs" location="libs"/>
<path id="class.path">
    <pathelement location="${libs}/testng-6.8.jar"/>
    <pathelement location="${libs}/selenium-java-2.40.0-srcs.jar"/>
    <pathelement location="${libs}/selenium-java-2.40.0.jar"/>
    <pathelement location="${libs}"/>
</path>
<taskdef name="test" classname="AntPackage.AntTest">
        <classpath>
            <pathelement location="libs/testng-6.8.jar"/>
        </classpath>
</taskdef>
<target name="runTest">
    <mkdir dir="testng_output"/>
    <testng outputdir="testng_output" classpathref="class.path">
        <xmlfileset dir="." includes="testng.xml"/>
    </testng>
</target>
</project>

,以下为testng.xml -

<?xml version="1.0" encoding="UTF-8"?>
<suite name="Suite" parallel="false">
    <test name="Test">
        <classes>
            <class name="AntPackage.AntTest"/>
        </classes>
    </test>
</suite>

AntTest类属于AntPackage类。

我在build.xml中根据taskdef任务的答案进行了更改,但无法找到,但它仍然不起作用。

不指定classname="AntPackage.AntTest",但根据<taskdef resource="testngtasks" classpath="${libs.dir}/testng-6.8.jar" />文档添加taskdef http://testng.org/doc/ant.html

`<taskdef />`  is needed to specify path to testng.jar but not your test classes

在build.xml中替换…

<taskdef name="test" classname="AntPackage.AntTest">
    <classpath>
        <pathelement location="libs/testng-6.8.jar"/>
    </classpath>
</taskdef>
与…

<taskdef resource="testngtasks" classpath="${libs}/testng-6.8.jar"/>

相关内容

  • 没有找到相关文章

最新更新