Skip to content

Commit

Permalink
#49: Test that ClassFilter is applied for methods
Browse files Browse the repository at this point in the history
  • Loading branch information
marcphilipp committed Jan 16, 2016
1 parent d243dd0 commit 5d09537
Showing 1 changed file with 19 additions and 2 deletions.
Expand Up @@ -507,6 +507,19 @@ void ignoresRedundantSelector() throws Exception {
"junit4:" + testClass.getName() + "/");
}

@Test
void doesNotResolveMethodOfClassNotAcceptedByClassFilter() throws Exception {
Class<?> testClass = PlainJUnit4TestCaseWithFiveTestMethods.class;
// @formatter:off
DiscoveryRequest request = request()
.select(byMethod(testClass, testClass.getMethod("failingTest")))
.filterBy(classNameMatches("Foo"))
.build();
// @formatter:on

assertYieldsNoDescriptors(request);
}

private TestDescriptor findChildByDisplayName(TestDescriptor runnerDescriptor, String displayName) {
// @formatter:off
Set<? extends TestDescriptor> children = runnerDescriptor.getChildren();
Expand All @@ -525,9 +538,13 @@ private File getClasspathRoot(Class<?> testClass) throws Exception {
}

private void assertYieldsNoDescriptors(Class<?> testClass) {
DiscoveryRequest specification = buildClassSpecification(testClass);
DiscoveryRequest request = buildClassSpecification(testClass);

TestDescriptor engineDescriptor = engine.discoverTests(specification);
assertYieldsNoDescriptors(request);
}

private void assertYieldsNoDescriptors(DiscoveryRequest request) {
TestDescriptor engineDescriptor = engine.discoverTests(request);

assertThat(engineDescriptor.getChildren()).isEmpty();
}
Expand Down

0 comments on commit 5d09537

Please sign in to comment.