Add a test scenario for @BeforeGroups having a dependsOnGroups - #2025
Add a test scenario for @BeforeGroups having a dependsOnGroups#2025jobayle wants to merge 1 commit into
Conversation
TestNG ignores the dependsongroups parameter on @BeforeGroups annotations.
|
Thanks for the test case but it doesn't follow the current convention. BTW, I suppose it is a graph issue not covered by tests. @krmahadevan Do you have time to check it? |
|
@jobayle - I am not sure if the test that you added is running as a group but it may be running as a standalone test. You would need to create a test that extends |
|
@krmahadevan Do you confirm the issue? |
|
@juherr I haven't got to this yet. I will get to this shortly. Since this is in the graph section, I would again need to brush up on its working :) |
Where can I read about this convention?
Me neither, also I tried to follow your instructions but eventually failed as I could not get it to work, sorry. |
|
@jobayle You can check a recent package test like https://github.com/cbeust/testng/tree/master/src/test/java/test/name |
A @BeforeGroups method is not a node of the scheduling graph: it is pulled dynamically, right before the first test method of a group it runs before, and MethodHelper.topologicalSort deliberately leaves the group dependencies of a group configuration method alone for that same reason. Nothing else read them, so the dependency reached no scheduler at all and @BeforeGroups(value = "A", dependsOnGroups = "Z") ran the whole of group A, configuration included, before group Z had started. DynamicGraphHelper now carries that dependency on the test methods of the target group, which is where it can be scheduled. The group a configuration runs before is matched by name, as ConfigurationGroupMethods does at invocation time; the group depended upon is matched by the same regex matcher the test methods' own dependsOnGroups uses, through the overload that answers empty rather than throwing -- a group holding no method in the current <test> stays the no-op it has always been. A method belonging to the group it would inherit the dependency upon is left out of it, since making every member of a group depend on the others is a cycle rather than a dependency. That exclusion asks the same expression that resolved the group, so dependsOnGroups = "Z.*" excludes a method in Z1 exactly as a plain name excludes a method in Z; deciding it by name while resolving it as a pattern made a suite whose group members overlap fail with an IllegalStateException. Skip-on-failure is unchanged: TestInvoker decides skips from the test method's own dependsOnGroups, so a failing Z orders A after it without skipping it. The regression test supersedes the standalone sample of PR testng-team#2025, whose scenario it keeps: priorities make the natural ordering prefer A over Z, so only the declared dependency can put Z first. Fix testng-team#2804
TestNG ignores the dependsongroups parameter on @BeforeGroups annotations.
See: https://stackoverflow.com/questions/31929690/beforegroups-method-ignores-dependsongroups