Skip to content

Tests for Ant projects no longer work with bundled TestNG libraries #9561

Closed

Description

@gem-bricks

Apache NetBeans version

Apache NetBeans 31

What happened

Using ant test or running individual tests in the IDE yields an error with an Ant project that uses the bundled TestNG libraries (added with Test Dependencies > Add Library...).

Language / Project Type / NetBeans Component

Ant project using TestNG

How to reproduce

  1. Create a new Ant project (New Project... > Java with Ant > Java Application). Keep Create Main Class checked.
  2. In the main class, click on the class name and select Create Test Class [TestNG... in the hints.
  3. Test the testMain method.

Did this work correctly in an earlier version?

Apache NetBeans 30

Operating System

linux 7.1.8.arch1-3

JDK

OpenJDK 26.0.2.u10-1

Apache NetBeans packaging

Community provided installer, Third-party package

Anything else

Example project

It has broken with 31 because TestNG has been bumped up to 7.11. The current build-impl.xml isn't equipped to handle the new major version.

Related to this issue.

Test output:

SLF4J(W): No SLF4J providers were found.
SLF4J(W): Defaulting to no-operation (NOP) logger implementation
SLF4J(W): See https://www.slf4j.org/codes.html#noProviders for further details.
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:59)
	at org.testng.ITestObjectFactory.newInstance(ITestObjectFactory.java:10)
	at org.testng.internal.objects.SimpleObjectDispenser.dispense(SimpleObjectDispenser.java:61)
	at org.testng.internal.objects.GuiceBasedObjectDispenser.dispenseObject(GuiceBasedObjectDispenser.java:41)
	at org.testng.internal.objects.GuiceBasedObjectDispenser.dispense(GuiceBasedObjectDispenser.java:31)
	at org.testng.internal.DefaultListenerFactory.createListener(DefaultListenerFactory.java:29)
	at org.testng.TestNG.setListenerClasses(TestNG.java:698)
	at org.testng.TestNG.configure(TestNG.java:1558)
	at org.testng.TestNG.privateMain(TestNG.java:1421)
	at org.testng.TestNG.main(TestNG.java:1394)

Are you willing to submit a pull request?

Yes

Activity

  1. added
    kind:bug
    needs:triage
    on Aug 15, 2026
  2. added
    Ant
    on Aug 16, 2026
  3. matthiasblaesing commented on Aug 16, 2026

    @matthiasblaesing
    Contributor

    This is most probably a fallout from #9254. Grepping through the codebase indicates, that the problem might be much bigger (grep -r org.testng.reporters.VerboseReporter * | grep -v "/test/").

    The minimal change I had to do to get basic execution working again was:

    diff --git a/java/java.j2seproject/src/org/netbeans/modules/java/j2seproject/resources/build-impl.xsl b/java/java.j2seproject/src/org/netbeans/modules/java/j2seproject/resources/build-impl.xsl
    index 7c4c00edb667..bc94091512a6 100644
    --- a/java/java.j2seproject/src/org/netbeans/modules/java/j2seproject/resources/build-impl.xsl
    +++ b/java/java.j2seproject/src/org/netbeans/modules/java/j2seproject/resources/build-impl.xsl
    @@ -1148,8 +1148,8 @@ is divided into following sections:
                             </union>
                             <taskdef name="testng" classname="org.testng.TestNGAntTask" classpath="${{run.test.classpath}}"/>
                             <testng>
    -                            <xsl:attribute name="listeners">org.testng.reporters.VerboseReporter</xsl:attribute>
                                 <xsl:attribute name="mode">${testng.mode}</xsl:attribute>
    +                            <xsl:attribute name="verbose">5</xsl:attribute>
                                 <xsl:attribute name="classfilesetref">test.set</xsl:attribute>
                                 <xsl:attribute name="workingDir">${work.dir}</xsl:attribute> <!-- #47474: match <java> --> 
                                 <xsl:attribute name="failureProperty">tests.failed</xsl:attribute>
    @@ -1369,7 +1369,7 @@ is divided into following sections:
                                     <jvmarg value="-ea"/>
                                     <arg line="${{testng.debug.mode}}"/>
                                     <arg line="-d ${{build.test.results.dir}}"/>
    -                                <arg line="-listener org.testng.reporters.VerboseReporter"/>
    +                                <arg line="-verbose 5"/>
                                     <arg line="${{testng.cmd.args}}"/>
                                 </customizeDebuggee>
                             </j2seproject3:debug>
    diff --git a/java/java.source.ant/src/org/netbeans/modules/java/source/ant/resources/junit-debug-snippet.xml b/java/java.source.ant/src/org/netbeans/modules/java/source/ant/resources/junit-debug-snippet.xml
    index e5c5a97df7cb..82040b057e23 100644
    --- a/java/java.source.ant/src/org/netbeans/modules/java/source/ant/resources/junit-debug-snippet.xml
    +++ b/java/java.source.ant/src/org/netbeans/modules/java/source/ant/resources/junit-debug-snippet.xml
    @@ -210,7 +210,7 @@
                         </syspropertyset>
                         <arg line="${testng.mode}"/>
                         <arg line="-d ${test.results.dir}"/>
    -                    <arg line="-listener org.testng.reporters.VerboseReporter"/>
    +                    <arg line="-verbose 5"/>
                         <arg line="${testng.cmd.args}"/>                                                                                                                                                                                                                                             
                     </java>
                     <delete dir="${test.results.dir}" quiet="true"/>
    diff --git a/java/java.source.ant/src/org/netbeans/modules/java/source/ant/resources/junit-profile-snippet.xml b/java/java.source.ant/src/org/netbeans/modules/java/source/ant/resources/junit-profile-snippet.xml
    index 96d3e2097006..03636f5e3e33 100644
    --- a/java/java.source.ant/src/org/netbeans/modules/java/source/ant/resources/junit-profile-snippet.xml
    +++ b/java/java.source.ant/src/org/netbeans/modules/java/source/ant/resources/junit-profile-snippet.xml
    @@ -190,7 +190,7 @@
                         </syspropertyset>
                         <arg line="${testng.mode}"/>
                         <arg line="-d ${test.result.dir}"/>
    -                    <arg line="-listener org.testng.reporters.VerboseReporter"/>
    +                    <arg line="-verbose 5"/>
                         <arg line="${testng.cmd.args}"/>
                     </java>
                     <delete dir="${test.result.dir}" quiet="true"/>
    diff --git a/java/java.source.ant/src/org/netbeans/modules/java/source/ant/resources/junit-snippet.xml b/java/java.source.ant/src/org/netbeans/modules/java/source/ant/resources/junit-snippet.xml
    index 0a50b31b6eb8..2ff989e00f62 100644
    --- a/java/java.source.ant/src/org/netbeans/modules/java/source/ant/resources/junit-snippet.xml
    +++ b/java/java.source.ant/src/org/netbeans/modules/java/source/ant/resources/junit-snippet.xml
    @@ -171,7 +171,7 @@
                         </syspropertyset>
                         <arg line="${testng.mode}"/>
                         <arg line="-d ${test.result.dir}"/>
    -                    <arg line="-listener org.testng.reporters.VerboseReporter"/>
    +                    <arg line="-verbose 5"/>
                         <arg line="${testng.cmd.args}"/>
                     </java>
                     <delete dir="${test.result.dir}" quiet="true"/>

    @sid-srini I think the hard part will be to find the other places that need love

  4. removed
    needs:triage
    on Aug 16, 2026
  5. sid-srini commented on Aug 24, 2026

    @sid-srini
    Contributor

    Thanks @matthiasblaesing for triaging this issue, along with the suggestions for fixes. I'm sorry that the PR #9254 included changes to the common ant templates, but did not include these junit snippets, xsl etc. I'll work on fixing such usages in various places asap.

    Apologies for the breakage.

  6. added this to the NB32 milestone on Aug 24, 2026
  7. gem-bricks commented on Sep 23, 2026

    @gem-bricks
    Author

    @matthiasblaesing I took a look at some parts of the code. Debugging TestNG tests may also break if TestNG is upgraded to version 8 in the future, as the main entrypoint as specified with j2seproject3:debug is deprecated and is planned to be removed with version 8. Maybe an adapter like this, compiled with the project (similar to how java.j2semodule builds Ant tasks), could fix it.

    package netbeans;
    
    import org.testng.TestNG;
    
    public class TestNGAdapter {
    
        public static void main(String[] args) {
            System.exit(TestNG.privateMain(args, null).getStatus());
        }
    
    }

    Although this is hacky and will also have to be implemented on a project type-by-type basis. Would it be best to start with a scoped pull request that only fixes java.j2seproject and java.source.ant? I compiled the modules you made changes for and installed them as plugins, and all of the usual features are working fine for me.

  8. matthiasblaesing commented on Sep 26, 2026

    @matthiasblaesing
    Contributor

    @gem-bricks I think that a partitial solution is ok. Of course a complete fix would be preferable, but each improvement counts. Before you start please have a look at #9641 so the work integrated there does not conflict with your changes.

  9. gem-bricks commented on Sep 26, 2026

    @gem-bricks
    Author

    @matthiasblaesing I'm okay with the changes with #9641. On second thought, fixing the potential test debugging issue is a bridge that will be crossed if TestNG removes that entry point and when NetBeans upgrades TestNG to 8.0, so I don't plan on working on it at the moment.

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

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions