0

I tried to run a single group as described in this question Can I run a specific testng test group via maven?

mvn test -Dgroups=debug

but keep getting this error:

org.apache.maven.surefire.util.SurefireReflectionException: java.lang.reflect.InvocationTargetException; nested exception is java.lang.reflect.InvocationTargetException: null
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
    at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175)
    at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:107)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68)
Caused by: java.lang.NullPointerException
    at testsuites.TestListener.onTestFailure(TestListener.java:32)
    at org.testng.internal.Invoker.runTestListeners(Invoker.java:1895)
    at org.testng.internal.Invoker.runTestListeners(Invoker.java:1879)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1292)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
    at org.testng.TestRunner.privateRun(TestRunner.java:767)
    at org.testng.TestRunner.run(TestRunner.java:617)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:348)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:343)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:305)
    at org.testng.SuiteRunner.run(SuiteRunner.java:254)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
    at org.testng.TestNG.run(TestNG.java:1057)
    at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:70)
    at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.executeMulti(TestNGDirectoryTestSuite.java:158)
    at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:98)
    at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:111)
    ... 9 more

Any idea what could be wrong? I have groups defined in pom.xml like this:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.10</version>
    <configuration>
        <groups>
            debug, test
        </groups>
        <properties>
            <property>
                <name>usedefaultlisteners</name>
                <value>true</value>
            </property>
        </properties>
        <includes>
                 <include>
                      testsuites/LoginTestSuite.java 
                </include>
          </includes>
     </configuration>
</plugin>

test itself is annotated with

@Test(groups = {"debug"})
Community
  • 1
  • 1
casper
  • 1,391
  • 2
  • 16
  • 29
  • at testsuites.TestListener.onTestFailure(TestListener.java:32) Is that one of your own classes? Because it is blowing up with an NPE. – Gimby May 05 '14 at 12:16
  • yes, that's my test listener and it's working just fine. At least when I do not specify groups. – casper May 05 '14 at 12:19
  • think I found the problem. I had to annotate setUp method with alwaysRun = true – casper May 05 '14 at 12:23
  • 1
    Yes but it is blowing up when you run the stuff differently, so its not as fine as you think it is. Possibly you've created a horror scenario where tests are influenced by each other and it depends on in which order they are invoked. My hair is falling out just thinking about it. – Gimby May 05 '14 at 12:23
  • almost. tests do rely on a setUp method :) – casper May 05 '14 at 12:26
  • You might want to rethink that, or use the `@BeforeClass` `@BeforeGroups` and `@BeforeSuite` annotations instead. – Mikkel Løkke May 05 '14 at 14:18
  • well, that's exactly what I was using - `@BeforeSuite`, but looks like maven ignores this annotation if it is not set to `alwaysRun = true` and if you specify a group name assigned only to some methods in a class. – casper May 05 '14 at 14:22

0 Answers0