问题:无法创建任务或输入 testng。原因:名称未定义

发布于 2024-09-14 08:18:08 字数 1314 浏览 1 评论 0原文

我在运行 testng 测试时遇到了一些问题。我使用 ant 任务调用测试,该任务返回以下错误消息:

BUILD FAILED
/**/build.xml:136:问题:无法创建任务或输入 testng
原因:名称未定义。
操作:检查拼写。
操作:检查是否已声明任何自定义任务/类型。
操作:检查是否存在任何/。声明已经发生。

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;

公共类伪测试{

@Test(groups = { "pseudoTest" })
公共无效aSingleTest(){
assert false : "简单测试失败并且不返回 true"; }
}

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

?感谢

BVA

i´ve got a little problem to run a testng test. I invoke the test with a ant task which returns following error message:

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.

The ant task looks like this:

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

This is the test class:

package **.pseudotest;

import org.apache.log4j.Logger;
import org.testng.annotations.Test;

public class PseudoTest {

@Test(groups = { "pseudoTest" })
public void aSingleTest() {
assert false : "The simple test failed and does not return true";
}
}

Can somebody help me to solve this problem?

Thanks

BVA

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

万劫不复 2024-09-21 08:18:08

听起来您需要将 TestNG 任务添加到 Ant。当遇到 标记时,它不知道要运行哪个类。

Sounds like you need to add the TestNG tasks to Ant. It doesn't know what class to run when it encounters the <testng> tag.

一个人的旅程 2024-09-21 08:18:08

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

I solved this problem installing:
plugin Java EE Base
and the problem was solved.

情魔剑神 2024-09-21 08:18:08

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

me to I just now solved this problem installing: plugin Java EE Base and the problem was solved.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文