55import org .junit .jupiter .api .Tag ;
66
77import java .lang .reflect .Method ;
8- import java .net .URLClassLoader ;
98import java .util .*;
109
1110@ Slf4j
@@ -15,30 +14,14 @@ private TagScanFacade() {}
1514
1615 public static Map <ExecutedTest , Set <String >> extractTagsFromExecutedTests (
1716 List <ExecutedTest > executedTests ,
18- URLClassLoader classLoader ) {
19-
17+ ClassLoader classLoader ) {
2018 Map <ExecutedTest , Set <String >> testTagMap = new LinkedHashMap <>();
21-
2219 for (ExecutedTest test : executedTests ) {
2320 try {
2421 Class <?> testClass = classLoader .loadClass (test .getClassName ());
2522 Method testMethod = findTestMethod (testClass , test .getMethodName ());
26-
2723 if (testMethod != null ) {
28- Set <String > tags = new HashSet <>();
29-
30- // Get tags from method
31- Tag [] methodTags = testMethod .getAnnotationsByType (Tag .class );
32- for (Tag tag : methodTags ) {
33- tags .add (tag .value ());
34- }
35-
36- // Get tags from class
37- Tag [] classTags = testClass .getAnnotationsByType (Tag .class );
38- for (Tag tag : classTags ) {
39- tags .add (tag .value ());
40- }
41-
24+ Set <String > tags = getMethodTag (testMethod , testClass );
4225 testTagMap .put (test , tags );
4326 } else {
4427 log .warn ("Could not find method: {} #{}" , test .getClassName (), test .getMethodName ());
@@ -49,10 +32,24 @@ public static Map<ExecutedTest, Set<String>> extractTagsFromExecutedTests(
4932 testTagMap .put (test , Collections .emptySet ());
5033 }
5134 }
52-
5335 return testTagMap ;
5436 }
5537
38+ private static Set <String > getMethodTag (Method testMethod , Class <?> testClass ) {
39+ Set <String > tags = new HashSet <>();
40+ // Get tags from method
41+ Tag [] methodTags = testMethod .getAnnotationsByType (Tag .class );
42+ for (Tag tag : methodTags ) {
43+ tags .add (tag .value ());
44+ }
45+ // Get tags from class
46+ Tag [] classTags = testClass .getAnnotationsByType (Tag .class );
47+ for (Tag tag : classTags ) {
48+ tags .add (tag .value ());
49+ }
50+ return tags ;
51+ }
52+
5653 private static Method findTestMethod (Class <?> testClass , String methodName ) {
5754 // Try exact match first
5855 for (Method method : testClass .getDeclaredMethods ()) {
0 commit comments