-
Notifications
You must be signed in to change notification settings - Fork 1k
fix(scheduling): honour dependsOnGroups declared by @BeforeGroups #3433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,7 +34,7 @@ | |
| /** Collection of helper methods to help sort and arrange methods. */ | ||
| public class MethodHelper { | ||
| private static final Map<ITestNGMethod[], Graph<ITestNGMethod>> GRAPH_CACHE = | ||
| new ConcurrentHashMap<>(); | ||
|
Check warning on line 37 in testng-core/src/main/java/org/testng/internal/MethodHelper.java
|
||
| private static final Map<Method, String> CANONICAL_NAME_CACHE = new ConcurrentHashMap<>(); | ||
| private static final Map<Pair<String, String>, Boolean> MATCH_CACHE = new ConcurrentHashMap<>(); | ||
|
|
||
|
|
@@ -353,6 +353,9 @@ | |
| } | ||
| predecessors.addAll(Arrays.asList(methodsNamed)); | ||
| } | ||
| // A group configuration method is left out: it is resolved against configuration methods of | ||
| // its own kind here, where a group names test methods. DynamicGraphHelper is what carries a | ||
| // @BeforeGroups dependsOnGroups over to the tests of the group it runs before. | ||
| boolean anyConfigExceptGroupConfigs = | ||
| !(m.isBeforeGroupsConfiguration() || m.isAfterGroupsConfiguration()); | ||
| boolean isGroupAgnosticConfigMethod = !m.isTest() && anyConfigExceptGroupConfigs; | ||
|
|
@@ -497,7 +500,7 @@ | |
| return result; | ||
| } | ||
|
|
||
| /** @return A sorted array containing all the methods 'method' depends on */ | ||
|
Check warning on line 503 in testng-core/src/main/java/org/testng/internal/MethodHelper.java
|
||
| public static List<ITestNGMethod> getMethodsDependedUpon( | ||
| ITestNGMethod method, ITestNGMethod[] methods, Comparator<ITestNGMethod> comparator) { | ||
| Graph<ITestNGMethod> g = GRAPH_CACHE.get(methods); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package test.beforegroups.issue2804; | ||
|
|
||
| import org.testng.annotations.BeforeGroups; | ||
| import org.testng.annotations.Test; | ||
|
|
||
| /** | ||
| * GITHUB-2804 (and the sample contributed by PR #2025): the priorities make the natural ordering | ||
| * prefer group {@code A} over group {@code Z}, so the only thing that can put {@code Z} first is | ||
| * the dependency declared by {@link #setUpA()}. | ||
| */ | ||
| public class GroupDependencySample { | ||
|
|
||
| @Test(groups = "A", priority = 1) | ||
| public void a1() {} | ||
|
|
||
| @Test(groups = "A", priority = 2) | ||
| public void a2() {} | ||
|
|
||
| @BeforeGroups(value = "A", dependsOnGroups = "Z") | ||
| public void setUpA() {} | ||
|
|
||
| @Test(groups = "Z", priority = 3) | ||
| public void z1() {} | ||
|
|
||
| @Test(groups = "Z", priority = 4) | ||
| public void z2() {} | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package test.beforegroups.issue2804; | ||
|
|
||
| import org.testng.annotations.BeforeGroups; | ||
| import org.testng.annotations.Test; | ||
|
|
||
| /** | ||
| * GITHUB-2804: {@code dependsOnGroups} names a group by regular expression, and {@link #az1()} and | ||
| * {@link #az2()} belong to both the group the configuration runs before and a group that expression | ||
| * matches. | ||
| */ | ||
| public class GroupPatternDependencySample { | ||
|
|
||
| @BeforeGroups(value = "A", dependsOnGroups = "Z.*") | ||
| public void setUpA() {} | ||
|
|
||
| @Test( | ||
| groups = {"A", "Z1"}, | ||
| priority = 1) | ||
| public void az1() {} | ||
|
|
||
| @Test( | ||
| groups = {"A", "Z1"}, | ||
| priority = 2) | ||
| public void az2() {} | ||
|
|
||
| @Test(groups = "Z2", priority = 3) | ||
| public void z3() {} | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.