Skip to content

Add a test scenario for @BeforeGroups having a dependsOnGroups - #2025

Open
jobayle wants to merge 1 commit into
testng-team:masterfrom
jobayle:bug/beforegroup-dependsongroups
Open

Add a test scenario for @BeforeGroups having a dependsOnGroups#2025
jobayle wants to merge 1 commit into
testng-team:masterfrom
jobayle:bug/beforegroup-dependsongroups

Conversation

@jobayle

@jobayle jobayle commented Mar 5, 2019

Copy link
Copy Markdown

TestNG ignores the dependsongroups parameter on @BeforeGroups annotations.

See: https://stackoverflow.com/questions/31929690/beforegroups-method-ignores-dependsongroups

TestNG ignores the dependsongroups parameter on @BeforeGroups
annotations.
@juherr

juherr commented Mar 7, 2019

Copy link
Copy Markdown
Member

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?

@juherr juherr added this to the 7.0 milestone Mar 7, 2019
@juherr juherr added Feature: before/after @BeforeX / @AfterX configuration methods Feature: groups Test groups (include/exclude) Feature: dependsOn dependsOnMethods / dependsOnGroups ordering labels Mar 7, 2019
@krmahadevan

Copy link
Copy Markdown
Member

@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 test.SimpleBaseTest and within an @Test method you would need to create a suite object add the group filtering, instantiate the TestNG object and then run the tests with it.

@juherr

juherr commented Mar 10, 2019

Copy link
Copy Markdown
Member

@krmahadevan Do you confirm the issue?

@krmahadevan

Copy link
Copy Markdown
Member

@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 :)

@jobayle

jobayle commented Mar 11, 2019

Copy link
Copy Markdown
Author

Thanks for the test case but it doesn't follow the current convention.

Where can I read about this convention?

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 test.SimpleBaseTest and within an @test method you would need to create a suite object add the group filtering, instantiate the TestNG object and then run the tests with it.

Me neither, also I tried to follow your instructions but eventually failed as I could not get it to work, sorry.

@juherr

juherr commented Mar 11, 2019

Copy link
Copy Markdown
Member

@jobayle You can check a recent package test like https://github.com/cbeust/testng/tree/master/src/test/java/test/name
You'll find a *Test which runs *Sample

juherr added a commit to juherr/testng that referenced this pull request Aug 27, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature: before/after @BeforeX / @AfterX configuration methods Feature: dependsOn dependsOnMethods / dependsOnGroups ordering Feature: groups Test groups (include/exclude)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants