IoannisDermitzakis 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_r331973700
##########
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:
Hi @Tibor17, I am halfway through the changes, but my time is currently very
limited. I estimate I'll post an updated PR within the next two weeks.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services