Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
velma committed Apr 25, 2022
1 parent 43c38c2 commit 561f183
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,23 +90,25 @@ public List<ITestNGMethod> getAfterGroupMethods(ITestNGMethod testMethod) {
.map(t -> retrieve(afterGroupsThatHaveAlreadyRun, m_afterGroupsMethods, t))
.filter(Objects::nonNull)
.flatMap(Collection::stream)
.filter(
afterGroupMethod -> {
String[] afterGroupMethodGroups = afterGroupMethod.getAfterGroups();
if (afterGroupMethodGroups.length == 1
|| methodGroups.containsAll(Arrays.asList(afterGroupMethodGroups))) {
return true;
}
return Arrays.stream(afterGroupMethodGroups)
.allMatch(
t ->
methodGroups.contains(t)
|| !CollectionUtils.hasElements(m_afterGroupsMap.get(t)));
})
.filter(t -> isAfterGroupAllowedToRunAfterTestMethod(t, methodGroups))
.collect(Collectors.toList());
}
}

private boolean isAfterGroupAllowedToRunAfterTestMethod(
ITestNGMethod afterGroupMethod, Set<String> testMethodGroups) {
String[] afterGroupMethodGroups = afterGroupMethod.getAfterGroups();
if (afterGroupMethodGroups.length == 1
|| testMethodGroups.containsAll(Arrays.asList(afterGroupMethodGroups))) {
return true;
}
return Arrays.stream(afterGroupMethodGroups)
.allMatch(
t ->
testMethodGroups.contains(t)
|| !CollectionUtils.hasElements(m_afterGroupsMap.get(t)));
}

public void removeBeforeGroups(String[] groups) {
for (String group : groups) {
m_beforeGroupsMethods.remove(group);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public void ensureAfterGroupsInvokedAfterAllTestsWhenMultipleGroupsDefined() {

tng.run();

assertThat(adapter.getPassedConfiguration()).hasSize(1);
ITestResult afterGroup = adapter.getPassedConfiguration().iterator().next();
adapter
.getPassedTests()
Expand Down

0 comments on commit 561f183

Please sign in to comment.