3

我有一个小问题要运行 testng 测试。我使用 ant 任务调用测试,该任务返回以下错误消息:

BUILD FAILED
/**/build.xml:136: Problem: failed to create task or type testng
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.

ant 任务如下所示:

<target name="test-start" depends="test-compile" description="Runs the TestNG tests">
    <testng 
        suitename="pseudo test"
        haltOnFailure="true"
        verbose="2"
        groups="pseudoTest">
        <classpath refid="test.classpath" />
        <classfileset dir="${build.testclasses.dir}" includes="**/*.class" />
    </testng>
</target>

<path id="test.classpath">
    <fileset dir="${lib.dir}">
        <include name="**/*.jar"/>
    </fileset>
    <pathelement path="${extralib.dir}/testng-5.13.1.jar" />
    <pathelement path="${build.testclasses.dir}" />
</path>

这是测试类:

包**.pseudotest;

导入 org.apache.log4j.Logger;
导入 org.testng.annotations.Test;

公共类 PseudoTest {

@Test(groups = { "pseudoTest" })
public void aSingleTest() {
assert false : "简单测试失败,不返回 true"; }
}

有人可以帮我解决这个问题吗?

谢谢

英属维尔京群岛

4

3 回答 3

1

听起来您需要将 TestNG 任务添加到 Ant。<testng>当它遇到标签时,它不知道要运行什么类。

于 2010-08-17T12:19:10.833 回答
0

我解决了这个问题安装: 插件Java EE Base ,问题就解决了。

于 2017-11-07T20:40:32.923 回答
0

我刚刚解决了这个问题安装:plugin Java EE Base,问题就解决了。

于 2021-05-30T14:40:19.627 回答