eclipse 问题:无法创建任务或键入 testng。原因:名称未定义
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3502123/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Problem: failed to create task or type testng. Cause: The name is undefined
提问by LuckyMalaka
i′ve got a little problem to run a testng test. I invoke the test with a ant task which returns following error message:
我在运行 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.
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:
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>
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"; }
}
包**.pseudotest;
导入 org.apache.log4j.Logger;
导入 org.testng.annotations.Test;公共类伪测试{
@Test(groups = { "pseudoTest" })
public void aSingleTest() {
assert false : "简单测试失败,不返回真"; }
}
Can somebody help me to solve this problem?
有人可以帮我解决这个问题吗?
Thanks
谢谢
BVA
BVA
采纳答案by duffymo
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.
听起来您需要将 TestNG 任务添加到 Ant 中。它不知道遇到<testng>
标签时运行什么类。
回答by Yorsh
I solved this problem installing: plugin Java EE Baseand the problem was solved.
我解决了这个问题安装: plugin Java EE Base,问题就解决了。