Skip to content

Commit

Permalink
Be more specific about the constraints for a test class
Browse files Browse the repository at this point in the history
  • Loading branch information
jlink committed Oct 31, 2015
1 parent ae9d12a commit e3f9b16
Showing 1 changed file with 13 additions and 0 deletions.
Expand Up @@ -10,13 +10,26 @@

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

import java.lang.reflect.Modifier;
import java.util.Arrays;

class TestClassTester {

private final TestMethodTester methodTester = new TestMethodTester();

boolean accept(Class<?> testClassCandidate) {
if (isAbstract(testClassCandidate))
return false;
if (testClassCandidate.isLocalClass())
return false;
return hasTestMethods(testClassCandidate);
}

private boolean isAbstract(Class<?> testClassCandidate) {
return (testClassCandidate.getModifiers() & Modifier.ABSTRACT) != 0;
}

private boolean hasTestMethods(Class<?> testClassCandidate) {
return Arrays.stream(testClassCandidate.getDeclaredMethods()).anyMatch(methodTester::accept);
}

Expand Down

0 comments on commit e3f9b16

Please sign in to comment.