Skip to content

Commit 561f183

Browse files
committed
review comments
1 parent 43c38c2 commit 561f183

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

testng-core/src/main/java/org/testng/internal/ConfigurationGroupMethods.java

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -90,23 +90,25 @@ public List<ITestNGMethod> getAfterGroupMethods(ITestNGMethod testMethod) {
9090
.map(t -> retrieve(afterGroupsThatHaveAlreadyRun, m_afterGroupsMethods, t))
9191
.filter(Objects::nonNull)
9292
.flatMap(Collection::stream)
93-
.filter(
94-
afterGroupMethod -> {
95-
String[] afterGroupMethodGroups = afterGroupMethod.getAfterGroups();
96-
if (afterGroupMethodGroups.length == 1
97-
|| methodGroups.containsAll(Arrays.asList(afterGroupMethodGroups))) {
98-
return true;
99-
}
100-
return Arrays.stream(afterGroupMethodGroups)
101-
.allMatch(
102-
t ->
103-
methodGroups.contains(t)
104-
|| !CollectionUtils.hasElements(m_afterGroupsMap.get(t)));
105-
})
93+
.filter(t -> isAfterGroupAllowedToRunAfterTestMethod(t, methodGroups))
10694
.collect(Collectors.toList());
10795
}
10896
}
10997

98+
private boolean isAfterGroupAllowedToRunAfterTestMethod(
99+
ITestNGMethod afterGroupMethod, Set<String> testMethodGroups) {
100+
String[] afterGroupMethodGroups = afterGroupMethod.getAfterGroups();
101+
if (afterGroupMethodGroups.length == 1
102+
|| testMethodGroups.containsAll(Arrays.asList(afterGroupMethodGroups))) {
103+
return true;
104+
}
105+
return Arrays.stream(afterGroupMethodGroups)
106+
.allMatch(
107+
t ->
108+
testMethodGroups.contains(t)
109+
|| !CollectionUtils.hasElements(m_afterGroupsMap.get(t)));
110+
}
111+
110112
public void removeBeforeGroups(String[] groups) {
111113
for (String group : groups) {
112114
m_beforeGroupsMethods.remove(group);

testng-core/src/test/java/test/aftergroups/AfterGroupsBehaviorTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public void ensureAfterGroupsInvokedAfterAllTestsWhenMultipleGroupsDefined() {
4646

4747
tng.run();
4848

49+
assertThat(adapter.getPassedConfiguration()).hasSize(1);
4950
ITestResult afterGroup = adapter.getPassedConfiguration().iterator().next();
5051
adapter
5152
.getPassedTests()

0 commit comments

Comments
 (0)