[ 
https://jira.codehaus.org/browse/SUREFIRE-829?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=291032#comment-291032
 ] 

Gayathri Muralidharan commented on SUREFIRE-829:
------------------------------------------------

Modified surefire-plugin version 2.12 locally and now it works for 1-level 
inheritance. (Trying to extend this for n-level inheritance as well)

Can someone please let me know if this is the correct approach ?
diff is as follows :

Index: 
surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/JUnit48Reflector.java
===================================================================
--- 
surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/JUnit48Reflector.java
      (revision 1241425)
+++ 
surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/JUnit48Reflector.java
      (working copy)
@@ -47,6 +47,6 @@

     public boolean isCategoryAnnotationPresent( Class clazz )
     {
-        return category != null && clazz.getAnnotation( category ) != null;
+               return (category != null && ((clazz.getAnnotation( category ) 
!= null) || (clazz.getSuperclass().getAnnotation( category ) != null) ));
     }
 }
Index: 
surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/FilterFactory.java
===================================================================
--- 
surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/FilterFactory.java
 (revision 1241425)
+++ 
surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/FilterFactory.java
 (working copy)
@@ -206,7 +206,7 @@
         {
             return shouldRun( description, ( description.getMethodName() == 
null
                 ? null
-                : Description.createSuiteDescription( 
description.getTestClass() ) ) );
+                : Description.createSuiteDescription( 
description.getTestClass().getSuperclass() ) ) );
         }

                
> junit | Support inheritance while running test cases belonging to a 
> particular category/group
> ---------------------------------------------------------------------------------------------
>
>                 Key: SUREFIRE-829
>                 URL: https://jira.codehaus.org/browse/SUREFIRE-829
>             Project: Maven Surefire
>          Issue Type: Bug
>          Components: Junit 4.x support
>    Affects Versions: 2.12
>            Reporter: Gayathri Muralidharan
>
> We have a parent class which is extended by all the unit test cases (multi 
> module maven based project)
> It would be great if surefire plugin config looks for the category in parent 
> class as well. This will avoid redundant @Category(UnitTestCategory.class) 
> annotations, as we expect all unit test cases to extend the corresponding 
> base class and the base class will alone be annotated with 
> @Category(UnitTestCategory.class)
> Please let me know if this can be achieved by any other config.
> Thanks,
> Gayathri

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://jira.codehaus.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to