diff --git a/approvaltests/src/main/java/org/approvaltests/namer/AttributeStackSelector.java b/approvaltests/src/main/java/org/approvaltests/namer/AttributeStackSelector.java index 0ff26d0d..03bf11c5 100644 --- a/approvaltests/src/main/java/org/approvaltests/namer/AttributeStackSelector.java +++ b/approvaltests/src/main/java/org/approvaltests/namer/AttributeStackSelector.java @@ -111,22 +111,16 @@ private boolean isJunit3Test(Class clazz) private boolean isTestAttribute(Class clazz, String methodName) { Queryable methods = getMethodsByName(clazz, methodName); - for (Method method : methods) - { - for (Class attribute : attributes) - { - if (method.isAnnotationPresent(attribute)) - { - checkConditionsForAttribute(attribute); - return true; - } - } - } - return false; + Class attribute = Queryable.as(attributes) // + .first(a -> methods.any(m -> m.isAnnotationPresent(a))); + checkConditionsForAttribute(attribute); + return attribute != null; } // TODO: clean this up, should be pluggable private static void checkConditionsForAttribute(Class attribute) { + if (attribute == null) + { return; } if ("org.junit.jupiter.api.TestFactory".equals(attribute.getName())) { if (!isDynamicWrapperPresent())