Skip to content

Running tests with TestNG fails #6737

Open

Description

@matty-r

Apache NetBeans version

Apache NetBeans 19

What happened

Attempt to run tests with TestNG installed in the classpath, I get the following error

Exception in thread "main" org.testng.TestNGException:
Couldn't find a constructor in class org.testng.reporters.VerboseReporter
                at org.testng.internal.objects.InstanceCreator.newInstance(instancecreator.java:57)
                at org.testng.ITestObjectFactory.newInstance(itestobjectfactory.java:10)

....

How to reproduce

Install TestNG with required dependencies and run a test.

Did this work correctly in an earlier version?

No / Don't know

Operating System

Windows

JDK

17

Apache NetBeans packaging

Apache NetBeans provided installer

Anything else

It works correctly if I run the test via a Test Runner, but if I right click and select run file or test file it throws that error.
I narrowed it down to the TestNGAntTask in the build-impl.XML file where the listeners attribute has the VerboseReporter package listed - if I remove that it works.

Are you willing to submit a pull request?

No

Activity

  1. added
    kind:bug
    needs:triage
    on Nov 22, 2023
  2. matty-r commented on Nov 22, 2023

    @matty-r
    Author

    I've been able to reproduce this on two separate machines.

    All libraries are in the classpath:

    image

    Error message:

    Couldn't find a constructor in class org.testng.reporters.VerboseReporter
    	at org.testng.internal.objects.InstanceCreator.newInstance(InstanceCreator.java:57)
    	at org.testng.ITestObjectFactory.newInstance(ITestObjectFactory.java:10)
    	at org.testng.TestNG.setListenerClasses(TestNG.java:684)
    	at org.testng.TestNG.configure(TestNG.java:1549)
    	at org.testng.TestNG.privateMain(TestNG.java:1431)
    	at org.testng.TestNG.main(TestNG.java:1404)
    

    This is there the VerboseReporter is referenced in the build-impl.xml

        <target if="${testng.available}" name="-init-macrodef-testng">
            <macrodef name="testng" uri="http://www.netbeans.org/ns/j2se-project/3">
                <attribute default="${includes}" name="includes"/>
                <attribute default="${excludes}" name="excludes"/>
                <attribute default="**" name="testincludes"/>
                <attribute default="" name="testmethods"/>
                <element name="customize" optional="true"/>
                <sequential>
                    <condition else="" property="testng.methods.arg" value="@{testincludes}.@{testmethods}">
                        <isset property="test.method"/>
                    </condition>
                    <union id="test.set">
                        <fileset dir="${test.tests.dir}" excludes="@{excludes},**/*.xml,${excludes}" includes="@{includes}">
                            <filename name="@{testincludes}"/>
                        </fileset>
                    </union>
                    <taskdef classname="org.testng.TestNGAntTask" classpath="${run.test.classpath}" name="testng"/>
                    <testng classfilesetref="test.set" failureProperty="tests.failed" listeners="org.testng.reporters.VerboseReporter" methods="${testng.methods.arg}" mode="${testng.mode}" outputdir="${build.test.results.dir}" suitename="urchat" testname="TestNG tests" workingDir="${work.dir}">
                        <xmlfileset dir="${build.test.classes.dir}" includes="@{testincludes}"/>
                        <propertyset>
                            <propertyref prefix="test-sys-prop."/>
                            <mapper from="test-sys-prop.*" to="*" type="glob"/>
                        </propertyset>
                        <classpath>
                            <path path="${run.test.classpath}"/>
                        </classpath>
                        <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
                        <customize/>
                    </testng>
                </sequential>
            </macrodef>
        </target>
  3. added
    Ant
    on Nov 24, 2023
  4. bdrx312 commented on Dec 6, 2024

    @bdrx312

    I have also run into this error when trying to use testng 7.10.2 and testng-ant 1.0.0. Is is there any solution or work around for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Antkind:bugneeds:triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions