maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [maven-surefire] Tibor17 commented on a change in pull request #248: SUREFIRE-1695 Support multiple inheritance of @Categories
Date Sat, 02 Nov 2019 22:20:44 GMT
Tibor17 commented on a change in pull request #248: SUREFIRE-1695 Support multiple inheritance
of @Categories
URL: https://github.com/apache/maven-surefire/pull/248#discussion_r341827879
 
 

 ##########
 File path: surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/GroupMatcherCategoryFilter.java
 ##########
 @@ -63,33 +63,50 @@
     @Override
     public boolean shouldRun( Description description )
     {
-        if ( description.getMethodName() == null || description.getTestClass() == null )
-        {
+        if(invalidTestClass(description)){
             return shouldRun( description, null, null );
         }
-        else
+
+        if (describesTestClass(description)) // is a test class
+        {
+            Class<?> testClass = description.getTestClass();
+            return shouldRun( description, null, testClass );
+        }
+        else // is a test method
         {
             Class<?> testClass = description.getTestClass();
             return shouldRun( description, createSuiteDescription( testClass ), testClass
);
         }
     }
 
+    private boolean describesTestClass(Description description) {
+        // Description parser in Junit 4.8 can return "null" String.
+        return description.getMethodName() == null || description.getMethodName().equals("null");
+    }
+
+    private boolean invalidTestClass(Description description) {
+        return description.getTestClass() == null;
+    }
+
     private static void findSuperclassCategories( Set<Class<?>> cats, Class<?>
clazz )
     {
-        if ( clazz != null && clazz.getSuperclass() != null )
+        if (hasSuperclass(clazz))
         {
             Category cat = clazz.getSuperclass().getAnnotation( Category.class );
             if ( cat != null )
             {
+                // Found categories in current superclass
                 addAll( cats, cat.value() );
             }
-            else
-            {
-                findSuperclassCategories( cats, clazz.getSuperclass() );
-            }
+            // Search the hierarchy
+            findSuperclassCategories( cats, clazz.getSuperclass() );
 
 Review comment:
   @YiannisDermitzakis
   @IoannisDermitzakis
   We will cut a new release version. If you wan to have this feature released soon, pls come
back to the discussion. Thx

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message