Skip to content

Commit

Permalink
Trying to resolve methods that are not test methods is logged as info
Browse files Browse the repository at this point in the history
  • Loading branch information
jlink authored and bechte committed Apr 29, 2016
1 parent 24e0a90 commit 6bf76b6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public void testNonResolvableUniqueId() {
"Exception message wrong: " + exception.getMessage());
}

// @Test
@Test
public void resolvingUniqueIdOfNonTestMethodResolvesNothing() {
UniqueIdSelector selector = UniqueIdSelector.forUniqueId(uniqueIdForMethod(MyTestClass.class, "notATest()"));
EngineDiscoveryRequest request = request().select(selector).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@

public class TestContainerResolver implements ElementResolver {

private static final Logger LOG = Logger.getLogger(TestContainerResolver.class.getName());
public static final String SEGMENT_TYPE = "class";

private static final String SEGMENT_TYPE = "class";
private static final Logger LOG = Logger.getLogger(TestContainerResolver.class.getName());

@Override
public Set<TestDescriptor> resolve(AnnotatedElement element, TestDescriptor parent) {
Expand All @@ -37,7 +37,7 @@ public Set<TestDescriptor> resolve(AnnotatedElement element, TestDescriptor pare

Class<?> clazz = (Class<?>) element;
if (!isPotentialTestContainer(clazz)) {
LOG.warning(() -> {
LOG.info(() -> {
String classDescription = clazz.getName();
return format("Class '%s' is not a test container", classDescription);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@

package org.junit.gen5.engine.junit5.discoveryNEW;

import static java.lang.String.format;

import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.Optional;
import java.util.Set;
import java.util.logging.Logger;

import org.junit.gen5.engine.TestDescriptor;
import org.junit.gen5.engine.UniqueId;
Expand All @@ -27,6 +30,8 @@ public class TestMethodResolver implements ElementResolver {

public static final String SEGMENT_TYPE = "method";

private static final Logger LOG = Logger.getLogger(TestMethodResolver.class.getName());

private boolean canResolveElement(AnnotatedElement element, TestDescriptor parent) {
//Do not collapse
if (!(element instanceof Method))
Expand All @@ -46,6 +51,11 @@ public Set<TestDescriptor> resolve(AnnotatedElement element, TestDescriptor pare

Method testMethod = (Method) element;
if (!isTestMethod(testMethod)) {
LOG.info(() -> {
String methodDescription = testMethod.getDeclaringClass().getName() + "#" + testMethod.getName();
return format("Method '%s' is not a test method", methodDescription);
});

return Collections.emptySet();
}

Expand Down

0 comments on commit 6bf76b6

Please sign in to comment.