Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Super class annotated with ITestNGListenerFactory makes derived test class throw TestNGException on execution #3095

Closed
1 of 7 tasks
RiJo opened this issue Mar 18, 2024 · 1 comment · Fixed by #3096
Closed
1 of 7 tasks

Comments

@RiJo
Copy link
Contributor

RiJo commented Mar 18, 2024

TestNG Version

7.9.0

Expected behavior

No problems running test method in derived test class where ITestNGListenerFactory annotation is present on super class.

Actual behavior

TestNG crashes during load:

org.testng.TestNGException: Found more than one class implementing ITestNGListenerFactory:class com.test.MyTestNgFactory and class com.test.MyTestNgFactory
	at org.testng.internal.TestListenerHelper.lambda$findAllListeners$0(TestListenerHelper.java:149)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at org.testng.internal.TestListenerHelper.findAllListeners(TestListenerHelper.java:139)
	at org.testng.TestRunner.initListeners(TestRunner.java:374)
	at org.testng.TestRunner.init(TestRunner.java:357)
	at org.testng.TestRunner.init(TestRunner.java:307)
	at org.testng.TestRunner.<init>(TestRunner.java:182)
	at org.testng.SuiteRunner$DefaultTestRunnerFactory.newTestRunner(SuiteRunner.java:652)
	at org.testng.SuiteRunner.init(SuiteRunner.java:224)
	at org.testng.SuiteRunner.<init>(SuiteRunner.java:116)
	at org.testng.TestNG.createSuiteRunner(TestNG.java:1396)
	at org.testng.TestNG.createSuiteRunners(TestNG.java:1370)
	at org.testng.TestNG.runSuitesLocally(TestNG.java:1219)
	at org.testng.TestNG.runSuites(TestNG.java:1134)
	at org.testng.TestNG.run(TestNG.java:1101)
	at com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:66)
	at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:105)

This is a regression in 7.9.0 as it was never seen in 7.8.0 or prior versions.

Is the issue reproducible on runner?

  • Shell
  • Maven
  • Gradle
  • Ant
  • Eclipse
  • IntelliJ
  • NetBeans

Test case sample

Running ChildClass#test() throws exception above.

@Listeners(MyTestNgFactory.class)
public static class SuperClass {
}

public static class ChildClass extends SuperClass {
    @Test
    public void child() {
    }
}

public static class MyTestNgFactory implements ITestNGListener, ITestNGListenerFactory {
    @Override
    public ITestNGListener createListener(Class<? extends ITestNGListener> listenerClass) {
        return null;
    }
}

Contribution guidelines

Incase you plan to raise a pull request to fix this issue, please make sure you refer our Contributing section for detailed set of steps.

@krmahadevan
Copy link
Member

@RiJo - Thanks for logging this issue. The root cause of this problem was because of this #3002

krmahadevan added a commit to krmahadevan/testng that referenced this issue Mar 19, 2024
krmahadevan added a commit to krmahadevan/testng that referenced this issue Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants