Uploaded image for project: 'Maven Surefire'
  1. Maven Surefire
  2. SUREFIRE-1062

TestNG listeners on separate lines in pom.xml

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.16
    • 2.17
    • TestNG support
    • None

    Description

      Currently, maven-surefire-plugin doesn't support setting TestNG listeners on the separate lines in pom.xml. User must put all listeners at the same line, so the line becomes very long.
      For example, for the following configuration the plugin throws unclear exception. It's very hard to determine the reason, cause the first idea is that something wrong with your classpath.

      ...
                              <property>
                                  <name>listener</name>
                                  <value>
                                      com.company1.testng.listeners.Listener1,
                                      com.company2.testng.listeners.Listener2
                                  </value>
                              </property>
      ...
      
      [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.16:test (default-test) on project allure-testng-example: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.16:test failed: There was an error in the forked process
      [ERROR] org.apache.maven.surefire.testset.TestSetFailedException: Cannot find listener class
      [ERROR] com.company2.testng.listeners.Listener2; nested exception is java.lang.ClassNotFoundException:
      [ERROR] com.company2.testng.listeners.Listener2
      [ERROR] java.lang.ClassNotFoundException:
      [ERROR] ru.befree.qa.tools.testng.listeners.LoggerListener
      [ERROR] at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
      [ERROR] at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
      [ERROR] at java.security.AccessController.doPrivileged(Native Method)
      [ERROR] at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
      [ERROR] at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
      [ERROR] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
      [ERROR] at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
      [ERROR] at java.lang.Class.forName0(Native Method)
      [ERROR] at java.lang.Class.forName(Class.java:190)
      [ERROR] at org.apache.maven.surefire.testng.conf.AbstractDirectConfigurator.loadClass(AbstractDirectConfigurator.java:139)
      [ERROR] at org.apache.maven.surefire.testng.conf.AbstractDirectConfigurator.loadListenerClasses(AbstractDirectConfigurator.java:127)
      [ERROR] at org.apache.maven.surefire.testng.conf.TestNGMapConfigurator.getConvertedOptions(TestNGMapConfigurator.java:81)
      [ERROR] at org.apache.maven.surefire.testng.conf.TestNG652Configurator.getConvertedOptions(TestNG652Configurator.java:40)
      [ERROR] at org.apache.maven.surefire.testng.conf.TestNGMapConfigurator.configure(TestNGMapConfigurator.java:52)
      [ERROR] at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:214)
      [ERROR] at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:84)
      [ERROR] at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:92)
      [ERROR] at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
      [ERROR] at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
      [ERROR] at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
      [ERROR] -> [Help 1]
      

      Is it a problem to fix AbstractDirectConfigurator class to split the value of listener property using new line symbols too?
      Current implementation is:

      String[] classNames = listenerClasses.split( " *, *" );
      

      Attachments

        Activity

          People

            agudian Andreas Gudian
            yuppie-flu Kirill Kozlov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: