cbeust/testng-eclipse — Issue #32: [eclipse-testng plugin] "dependsOnMethods" not resolved when using fully qualified method name
Author: fmisiak
Created: 2011-11-21 19:39:08+00:00
State: open

reposting from https://github.com/cbeust/testng/issues/132

Use case:
Suppose You have the following sources in an eclipse projects:

package packageA;
public class ClassOne {
@Test(dependsOnMethods = {"packageB.ClassTwo.methodB"})
public void methodA()
{
}
}

package packageB;
public class ClassTwo {
@Test()
public void methodB()
{
}
}

Now, from the Eclipse project Explorer (or package explorer, etc....), suppose you select "methodA" in ClassOne, right rick and select menu item "Run As/TestNG Test". You'll get the following error:

org.testng.TestNGException:
packageA.ClassOne.methodA() is depending on method public void packageB.ClassTwo.methodB(), which is not annotated with @Test
at org.testng.internal.MethodHelper.findDependedUponMethods(MethodHelper.java:95)
at org.testng.internal.MethodHelper.topologicalSort(MethodHelper.java:245)
at org.testng.internal.MethodHelper.sortMethods(MethodHelper.java:316)
at org.testng.internal.MethodHelper.collectAndOrderMethods(MethodHelper.java:51)
at org.testng.TestRunner.initMethods(TestRunner.java:477)
at org.testng.TestRunner.init(TestRunner.java:231)
at org.testng.TestRunner.init(TestRunner.java:201)
at org.testng.TestRunner.(TestRunner.java:157)
at org.testng.remote.RemoteTestNG$1.newTestRunner(RemoteTestNG.java:139)
at org.testng.remote.RemoteTestNG$DelegatingTestRunnerFactory.newTestRunner(RemoteTestNG.java:269)
at org.testng.SuiteRunner$ProxyTestRunnerFactory.newTestRunner(SuiteRunner.java:562)
at org.testng.SuiteRunner.init(SuiteRunner.java:157)
at org.testng.SuiteRunner.(SuiteRunner.java:111)
at org.testng.TestNG.createSuiteRunner(TestNG.java:1212)
at org.testng.TestNG.createSuiteRunners(TestNG.java:1199)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1053)
at org.testng.TestNG.run(TestNG.java:974)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:109)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:202)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:173)

You would expect instead that the plugin would resolve the dependency automatically and run before running the target method.

Note: If you set the dependency on a method that belongs to the same class (or a method defined in its super classes) then the dependency is correctly resolved (and more complex dependency chain seem to be resolve just fine).

The problem only occurs when the dependency points to a different class.

I debugged the issue to the implementation of:

org.testng.eclipse.util.JDTUtil.solveDependencies(MethodDefinition methodDef, Map parsedMethods)

I have a fix that I tested. I'll see if I can attach a patch file to this ticket.

Once my git/github environment is setup I'll propose a fix.