java - 问题 : failed to create task or type testng. 原因:名称未定义

标签 java eclipse ant testng

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

BUILD FAILED<br/> /**/build.xml:136: Problem: failed to create task or type testng<br/> Cause: The name is undefined.<br/> Action: Check the spelling.<br/> Action: Check that any custom tasks/types have been declared.<br/> 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>

这是测试类:

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"; }
}

谁能帮我解决这个问题?

谢谢

商业值(value)

最佳答案

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

关于java - 问题 : failed to create task or type testng. 原因:名称未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3502123/

相关文章:

java - Web服务器部署问题

java - 如何从Java中的响应中删除某些字符?

java - Spring junit Autowiring 自定义类必须有构造函数本身吗?

android - 在 Android 代码中制作错误消息

java - 无法将图像绘制到 JFrame

eclipse 发现资源未编译

java - Ant +JUnit : How to define VM for Junit?

java - 将项目从 Ant 移至 Maven 并将其分解

java - 如何替换 canoo webtest 中的 URL

java - Mockito:如何模拟 javax.inject.Provider 创建的原型(prototype) bean?