Skip to content

JUnit @ParameterizedTest in Gradle project not handled correctly by o.n.m.gsf.testrunner #8878

@wrprice

Description

@wrprice

Apache NetBeans version

Apache NetBeans 28 latest daily build

What happened

Unexpected error notification pops up after running tests:

java.lang.AssertionError
	at org.netbeans.modules.gsf.testrunner.ui.api.TestsuiteNode.displayReport(TestsuiteNode.java:208)
	at org.netbeans.modules.gsf.testrunner.ui.RootNodeChildren.displayReport(RootNodeChildren.java:174)
	at org.netbeans.modules.gsf.testrunner.ui.RootNode.displayReport(RootNode.java:160)
	at org.netbeans.modules.gsf.testrunner.ui.ResultPanelTree.displayReport(ResultPanelTree.java:192)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
	at java.base/java.lang.reflect.Method.invoke(Method.java:565)
[catch] at org.netbeans.modules.gsf.testrunner.ui.ResultDisplayHandler$3.run(ResultDisplayHandler.java:404)
	at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:723)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:702)
	at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:136)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

Narrowed the issue down to the following circumstances:

  1. Gradle Java project
  2. JUnit Jupiter tests
  3. Using @ParameterizedTest
  4. At least two separate JUnit test class files share the same method name (and both use @ParameterizedTest)

Under these circumstances, the assertion at TestsuiteNode.java:208 expects that the suiteName equals the report's getSuiteClassName() but this fails. Debugging a local build, report.getSuiteClassName() in this case appears to be the method name instead of the class name.

Expected:

Using the same situation with a Maven build, the Test Results window shows two classes with the parameterized tests nested within each:

Image

Actual (dev-02b2c5b1c830bad2a50a64d1818be6147db481c0):

Using a Gradle build, the parameterized test method name appears as its own suite, with only one set of results and it's unclear from which of the two test classes the results are reporting from:

Image

NB27 behavior:

NB27 doesn't bubble up the assertion, but notice that its Test Results window shows a different (broken) behavior -- the parameterized tests are listed twice, but the "normal" @Test methods and the class names are missing:

Image

Language / Project Type / NetBeans Component

Gradle Java project with JUnit 5 Jupiter tests

How to reproduce

Minimal reproducer Gradle project with test sources:

gradleproject.zip

Did this work correctly in an earlier version?

Apache NetBeans 27

Operating System

WSL2 on Windows 11

JDK

24.0.2; OpenJDK 64-Bit Server VM 24.0.2+12

Apache NetBeans packaging

Apache NetBeans binary zip

Anything else

No response

Are you willing to submit a pull request?

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Gradle[ci] enable "build tools" testskind:bugBug report or fixneeds:triageRequires attention from one of the committerstests

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions