private boolean shouldRun()

in surefire-providers/common-junit48/src/main/java/org/apache/maven/surefire/common/junit48/GroupMatcherCategoryFilter.java [104:152]


    private boolean shouldRun(Description description, Description parent, Class<?> parentClass) {
        if (matcher == null) {
            return true;
        } else {
            Set<Class<?>> cats = new HashSet<>();
            Category cat = description.getAnnotation(Category.class);
            if (cat != null) {
                // Found categories in current description
                addAll(cats, cat.value());
            }

            if (parent != null) {
                cat = parent.getAnnotation(Category.class);
                if (cat != null) {
                    // Found categories in current parent
                    addAll(cats, cat.value());
                }
            }
            if (parentClass != null) {
                findSuperclassCategories(cats, parentClass);
            }

            Class<?> testClass = description.getTestClass();
            if (testClass != null) {
                cat = testClass.getAnnotation(Category.class);
                if (cat != null) {
                    // Found categories in current testClass
                    addAll(cats, cat.value());
                }
            }

            cats.remove(null);
            boolean result = matcher.enabled(cats.toArray(new Class<?>[cats.size()]));

            if (!result) {
                ArrayList<Description> children = description.getChildren();
                if (children != null) {
                    for (Description child : children) {
                        if (shouldRun(child, description, null)) {
                            result = true;
                            break;
                        }
                    }
                }
            }

            return result;
        }
    }