[ https://jira.codehaus.org/browse/SUREFIRE-829?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=291033#comment-291033 ]
Gayathri Muralidharan commented on SUREFIRE-829: ------------------------------------------------ Modified for supporting n-level inheritance as well : Diff : 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,17 +206,23 @@ { return shouldRun( description, ( description.getMethodName() == null ? null - : Description.createSuiteDescription( description.getTestClass() ) ) ); + : Description.createSuiteDescription( description.getTestClass().getSuperclass() ) ) ); } private boolean shouldRun( Description description, Description parent ) { Boolean result = shouldRunAnswers.get( description ); - if ( result != null ) + Boolean parentResult = shouldRunAnswers.get( parent ); + if ( result != null ) { return result; } + if ( parentResult != null ) + { + return parentResult; + } + Please let me know if i am missing anything else here? Thanks, Gayathri > 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