apache / apache/maven-surefire
[SUREFIRE-1073] method depends on nonexistent group, but group exists
- Dominant language
- Java
- Stars
- 461
- Forks
- 588
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 19
Description
**[Brandon Heller](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=brandonh)** opened **[SUREFIRE-1073](https://issues.apache.org/jira/browse/SUREFIRE-1073?redirect=false)** and commented
When running a whole project's tests from the command-line via 'mvn test', test-ng test dependencies are correctly resolved, and all tests pass. When trying to run a single test from the command line that depends on another test, I get a 'method depends on nonexistent group' error, with this output:
```
....
objc[24281]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/bin/java and /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
Running com.fourwardnetworks.com.testngtest.TestNext
Configuring TestNG with: TestNG652Configurator
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.328s
[INFO] Finished at: Sat Apr 05 15:34:03 PDT 2014
[INFO] Final Memory: 27M/439M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test (default-test) on project core: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test failed: There was an error in the forked process
[ERROR] org.testng.TestNGException:
[ERROR] DependencyMap::Method "TestNext.runMeNext()[pri:0, instance:com.fourwardnetworks.com.testngtest.TestNext@6625abb1]" depends on nonexistent group "MyGroup"
[ERROR] at org.testng.DependencyMap.getMethodsThatBelongTo(DependencyMap.java:46)
[ERROR] at org.testng.TestRunner.createDynamicGraph(TestRunner.java:1074)
[ERROR] at org.testng.TestRunner.privateRun(TestRunner.java:734)
[ERROR] at org.testng.TestRunner.run(TestRunner.java:617)
[ERROR] at org.testng.SuiteRunner.runTest(SuiteRunner.java:348)
[ERROR] at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:343)
[ERROR] at org.testng.SuiteRunner.privateRun(SuiteRunner.java:305)
[ERROR] at org.testng.SuiteRunner.run(SuiteRunner.java:254)
[ERROR] at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
[ERROR] at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
[ERROR] at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
[ERROR] at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
[ERROR] at org.testng.TestNG.run(TestNG.java:1057)
[ERROR] at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:115)
[ERROR] at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.executeSingleClass(TestNGDirectoryTestSuite.java:128)
[ERROR] at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:112)
[ERROR] at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:112)
[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)
```
To replicate this, two files are sufficient:
TestNext.java
```
package com.fourwardnetworks.com.testngtest;
import org.testng.annotations.Test;
public class TestNext {
@Test(dependsOnGroups = { "MyGroup" })
public void runMeNext() { }
}
```
and TestFirst.java:
```
package com.fourwardnetworks.com.testngtest;
import org.testng.annotations.Test;
public class TestFirst {
@Test(groups = { "MyGroup" })
public void runMeFirst() { }
}
```
And then run from the cmd line:
```
mvn -Dtest=TestNext test
```
... you get the error above. When run from within Eclipse, by right-clicking on function testNext, then going to Debug As -> TestNG Test, the dependent test runs correctly for this test case, but not for the bug "in the wild" - no idea why.
Putting the two functions into one file, running from the command line, works as well. I have to assume it's some issue with generated config.
Any pointers to help fix this? Thanks.
---
**Affects:** 2.17
1 votes, 5 watchers
Contributor guide
Research direction
Start with the TestNext.java and TestFirst.java reproducer and run `mvn -Dtest=TestNext test` to confirm the nonexistent-group failure. Trace how the Surefire TestNG provider builds its generated configuration for a single test class, comparing it with the whole-project run. Done means the two-class command-line case resolves the dependency and passes without the reported error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system, testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100