@@ -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 );
0 commit comments