dependsOnMethod cyclic dependencies detected when none exist?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

dependsOnMethod cyclic dependencies detected when none exist?

romeara
This post has NOT been accepted by the mailing list yet.
Hi,

I am trying to write tests using TestNG, and have a problem that has appeared on a couple of occassions. I have tried searching existing forums, but the only related things I found were announcements on the dependsOnMethods element and someone having an issue when they didn't use the dependsOnMethods element.

My specific problem is that if I have a class with, say, 4 methods that are annotated as "@BeforeMethod" called A, B, C and D, and they have the following "dependsOnMethods" annotations:

A depends on B
B depends on C
C depends on D
D depends on nothing

I will get a "cyclic dependency" error when I try to run the tests on all 4 methods. As far as I see, there are no cyclic dependencies - the dependencies should just result in an execution order of D, C, B, A.

Did I miss some quirk of TestNG in the documentation, or is this a bug? If anyone has seen this before, if there a way around it?


Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: dependsOnMethod cyclic dependencies detected when none exist?

romeara
This post has NOT been accepted by the mailing list yet.
So additional information regarding this. I have found a way to work around it. If I change the above scenario to be:

A depends on B,C,D
B depends on C,D
C depends on D
D depends on nothing

Then the test runs correctly. I am confused about how the dependency analyzer didn't come up with the D,C,B,A solution to the first scenario, but I can now at least get last this occurrence.