diff --git a/archunit-junit/junit5/engine/src/main/java/com/tngtech/archunit/junit/internal/ArchUnitSystemPropertyTestFilterJUnit5.java b/archunit-junit/junit5/engine/src/main/java/com/tngtech/archunit/junit/internal/ArchUnitSystemPropertyTestFilterJUnit5.java index 0a7553d16..fcb9dc951 100644 --- a/archunit-junit/junit5/engine/src/main/java/com/tngtech/archunit/junit/internal/ArchUnitSystemPropertyTestFilterJUnit5.java +++ b/archunit-junit/junit5/engine/src/main/java/com/tngtech/archunit/junit/internal/ArchUnitSystemPropertyTestFilterJUnit5.java @@ -40,8 +40,7 @@ void filter(TestDescriptor descriptor) { String testFilterProperty = configuration.getProperty(JUNIT_TEST_FILTER_PROPERTY_NAME); List memberNames = Splitter.on(",").splitToList(testFilterProperty); - Predicate shouldRunPredicate = - testDescriptor -> !(testDescriptor instanceof AbstractArchUnitTestDescriptor) || memberNameMatches(testDescriptor, memberNames); + Predicate shouldRunPredicate = testDescriptor -> memberNameMatches(testDescriptor, memberNames); removeNonMatching(descriptor, shouldRunPredicate); } @@ -49,7 +48,7 @@ private void removeNonMatching(TestDescriptor descriptor, Predicate removeNonMatching(child, shouldRunPredicate)); - if (descriptor.getChildren().isEmpty() && !shouldRunPredicate.test(descriptor)) { + if (!descriptor.isRoot() && descriptor.getChildren().isEmpty() && !shouldRunPredicate.test(descriptor)) { descriptor.removeFromHierarchy(); } }