Problem: failed to create task or type testng. Cause: The name is undefined

18,899

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.

Share:
18,899
0xPixelfrost
Author by

0xPixelfrost

Updated on June 05, 2022

Comments

  • 0xPixelfrost
    0xPixelfrost almost 2 years

    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