I'm getting a "Cyclic graph of methods" error when running two tests that both extend from the same abstract superclass. Actually, there is an intermediate abstract test class that contains some @Test methods (no other annotated methods). And finally there are the two concrete test implementations that contain further @Test methods. I can run one of either of these tests without any problem but when I run them both together I get a cyclic dependency error.
The following code is a simplified version of my test classes:
public abstract class BaseIntegrationTest {
@BeforeClass(groups="integration")
protected void initIntegrationTesting() {
//...
}
@BeforeClass(groups="integration")
void executeBeforeClassDbOperations() {
//...
}
}
public abstract class AbstractGenericTests extends BaseIntegrationTest {
@Test(groups="integration")
public final void testSomething() {
//...
}
}
public class SomeConcreteTests extends AbstractGenericTests {
@Test(groups="integration")
public void testSomethingElse() {
//...
}
}
public class SomeMoreConcreteTests extends AbstractGenericTests {
@Test(groups="integration")
public void testSomethingOtherThing() {
//...
}
}
I'm using TestNG version 5.5 on JDK1.5.
The logging output and stack trace are below.
It'd be great if someone could offer some advice to point out what I'm doing wrong or maybe provide a workaround.
Cheers,
Kevin
[MethodInheritance] com.xxx.server.persist.HibernateIntegrationTest.executeBeforeClassDbOperations() DEPENDS ON com.xxx.server.persist.HibernateIntegrationTest.initIntegrationTesting()
[testng] [MethodInheritance] com.xxx.server.persist.HibernateIntegrationTest.initIntegrationTesting() DEPENDS ON com.xxx.server.persist.HibernateIntegrationTest.executeBeforeClassDbOperations()
[testng] [MethodInheritance] com.xxx.server.persist.HibernateIntegrationTest.executeBeforeClassDbOperations() DEPENDS ON com.xxx.server.persist.HibernateIntegrationTest.initIntegrationTesting()
[testng] ===============================================
[testng] Ant suite
[testng] Total tests run: 0, Failures: 0, Skips: 0
[testng] ===============================================
[testng] org.testng.TestNGException:
[testng] Cyclic graph of methods
[testng] at org.testng.internal.Graph.topologicalSort(Graph.java:122)
[testng] at org.testng.internal.MethodHelper.topologicalSort(MethodHelper.java:516)
[testng] at org.testng.internal.MethodHelper.sortMethods(MethodHelper.java:568)
[testng] at org.testng.internal.MethodHelper.collectAndOrderMethods(MethodHelper.java:82)
[testng] at org.testng.internal.MethodHelper.collectAndOrderMethods(MethodHelper.java:50)
[testng] at org.testng.TestRunner.initMethods(TestRunner.java:319)
[testng] at org.testng.TestRunner.init(TestRunner.java:198)
[testng] at org.testng.TestRunner.init(TestRunner.java:168)
[testng] at org.testng.TestRunner.<init>(TestRunner.java:127)
[testng] at org.testng.SuiteRunner$DefaultTestRunnerFactory.newTestRunner(SuiteRunner.java:418)
[testng] at org.testng.SuiteRunner.privateRun(SuiteRunner.java:212)
[testng] at org.testng.SuiteRunner.run(SuiteRunner.java:168)
[testng] at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:987)
[testng] at org.testng.TestNG.runSuitesLocally(TestNG.java:951)
[testng] at org.testng.TestNG.run(TestNG.java:719)
[testng] at org.testng.TestNG.privateMain(TestNG.java:1019)
[testng] at org.testng.TestNG.main(TestNG.java:997)
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=70619&messageID=132406#132406
[testng] [MethodInheritance] com.xxx.server.persist.HibernateIntegrationTest.executeBeforeClassDbOperations () DEPENDS ON com.xxx.server.persist.HibernateIntegrationTest.initIntegrationTesting()
[testng] ===============================================
[testng] Ant suite
[testng] Total tests run: 0, Failures: 0, Skips: 0
[testng] ===============================================
[testng] org.testng.TestNGException:
[testng] Cyclic graph of methods
[testng] at org.testng.internal.Graph.topologicalSort(Graph.java:122)
[testng] at org.testng.internal.MethodHelper.topologicalSort(MethodHelper.java:516)
[testng] at org.testng.internal.MethodHelper.sortMethods(MethodHelper.java:568)
[testng] at org.testng.internal.MethodHelper.collectAndOrderMethods (MethodHelper.java:82)
[testng] at org.testng.internal.MethodHelper.collectAndOrderMethods(MethodHelper.java:50)
[testng] at org.testng.TestRunner.initMethods(TestRunner.java:319)
[testng] at org.testng.TestRunner.init (TestRunner.java:198)
[testng] at org.testng.TestRunner.init(TestRunner.java:168)
[testng] at org.testng.TestRunner.<init>(TestRunner.java:127)
[testng] at org.testng.SuiteRunner$DefaultTestRunnerFactory.newTestRunner (SuiteRunner.java:418)
[testng] at org.testng.SuiteRunner.privateRun(SuiteRunner.java:212)
[testng] at org.testng.SuiteRunner.run(SuiteRunner.java:168)
[testng] at org.testng.TestNG.createAndRunSuiteRunners (TestNG.java:987)
[testng] at org.testng.TestNG.runSuitesLocally(TestNG.java:951)
[testng] at org.testng.TestNG.run(TestNG.java:719)
[testng] at org.testng.TestNG.privateMain(TestNG.java:1019)
[testng] at org.testng.TestNG.main(TestNG.java:997)
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=70619&messageID=132406#132406
I'm not quite sure what you mean. None of my classes have any dependsOnGroups or dependsOnMethods annotations in them. Are you saying that I am supposed to have a dependsOnGroups, or were you thinking that I must have had one in there somewhere that would be causing the error?
So, just to confirm, I'm not explicitly creating any dependencies using annotations. The error message says that one of the @BeforeClass methods defined in the top-level base class is dependent on the other @BeforeClass method in the same base class, and vice-versa. But this error only shows up when running more than one concrete test subclass at the same time.
If you give me some time I'll write some trimmed down classes to reproduce the error and attach them to this thread.
Thanks again for the reply
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=70619&messageID=132455#132455
--
Cédric
1. Extract the jar file somewhere, this creates a directory called testng-cyclic-dependency.
2. CD into this directory.
3. Copy testng-5.5-jdk15.jar into this directory.
4. run ant from the command line
The default ant target runs both test subclasses and shows up the error. There are also targets to run each test class individually, without errors.
I hope this helps
Cheers,
Kevin
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=70619&messageID=132460#132460
--
Cédric