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

ITestNGListenerFactory is broken and never invoked #3120

Open
1 of 7 tasks
RiJo opened this issue May 2, 2024 · 3 comments
Open
1 of 7 tasks

ITestNGListenerFactory is broken and never invoked #3120

RiJo opened this issue May 2, 2024 · 3 comments

Comments

@RiJo
Copy link
Contributor

RiJo commented May 2, 2024

TestNG Version

7.10.2

Worked as expected in 7.8.0

Expected behavior

When a ITestNGListenerFactory implementation is registered via @Listeners annotation, ITestNGListenerFactory#createListener should be invoked before any @Test annotated methods are invoked.

Actual behavior

ITestNGListenerFactory#createListener is never invoked.

Is the issue reproducible on runner?

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

Test case sample

  1. Factory is part of test class:
@Listeners(FactoryListenerTest.class)
public class FactoryListenerTest implements ITestNGListener, ITestNGListenerFactory {

    @Override
    public ITestNGListener createListener(Class<? extends ITestNGListener> listenerClass) {
        // Never invoked
        System.out.println("FactoryListenerTest.createListener");
        return null;
    }

    @Test
    public void test() {
        System.out.println("FactoryListenerTest.test");
    }
}
  1. Independent factory
public class CustomFactory implements ITestNGListener, ITestNGListenerFactory {

    @Override
    public ITestNGListener createListener(Class<? extends ITestNGListener> aClass) {
        // Never invoked
        System.out.println("CustomFactory.createListener");
        return null;
    }
}

@Listeners(CustomFactory.class)
public class FactoryListenerTest {

    @Test
    public void test() {
        System.out.println("FactoryListenerTest.test");
    }
}

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 krmahadevan added this to the 7.11.0 milestone May 2, 2024
@krmahadevan
Copy link
Member

Root cause of this issue was because of this PR #3060

@krmahadevan
Copy link
Member

@RiJo - Until this issue is fixed, can you please try adding

<properties>
   <property>
      <name>listenerfactory</name>
      <value>your.fully.qualified.classname.goes.here</value>
  </property>
</properties>

This should ensure that your listener factory gets invoked when you run your tests using maven.

For running tests via intellij you can set this configurmation via the Test runner params

image

@RiJo
Copy link
Contributor Author

RiJo commented May 2, 2024

Thanks for the quick response!

It is not possible for me to add custom parameters and/or properties as the TestNG tests are part of a larger system. I will stay on version 7.8.0 until the issue has been addressed. Thanks!

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

No branches or pull requests

2 participants