use of org.junit.platform.engine.discovery.MethodSelector in project junit5 by junit-team.
the class TestClassWithTemplate method methodResolution.
@Test
void methodResolution() throws NoSuchMethodException {
Method test1 = MyTestClass.class.getDeclaredMethod("test1");
MethodSelector selector = selectMethod(test1.getDeclaringClass(), test1);
resolver.resolveSelectors(request().selectors(selector).build(), engineDescriptor);
assertEquals(2, engineDescriptor.getDescendants().size());
List<UniqueId> uniqueIds = uniqueIds();
assertThat(uniqueIds).contains(uniqueIdForClass(MyTestClass.class));
assertThat(uniqueIds).contains(uniqueIdForMethod(MyTestClass.class, "test1()"));
}
use of org.junit.platform.engine.discovery.MethodSelector in project junit5 by junit-team.
the class TestClassWithTemplate method resolvingSelectorOfNonTestMethodResolvesNothing.
@Test
void resolvingSelectorOfNonTestMethodResolvesNothing() throws NoSuchMethodException {
Method notATest = MyTestClass.class.getDeclaredMethod("notATest");
MethodSelector selector = selectMethod(notATest.getDeclaringClass(), notATest);
EngineDiscoveryRequest request = request().selectors(selector).build();
resolver.resolveSelectors(request, engineDescriptor);
assertTrue(engineDescriptor.getDescendants().isEmpty());
}
use of org.junit.platform.engine.discovery.MethodSelector in project junit5 by junit-team.
the class DiscoveryRequestCreatorTests method convertsMethodSelectors.
@Test
void convertsMethodSelectors() {
options.setSelectedMethods(asList("com.acme.Foo#m()", "com.example.Bar#method(java.lang.Object)"));
LauncherDiscoveryRequest request = convert();
List<MethodSelector> methodSelectors = request.getSelectorsByType(MethodSelector.class);
assertThat(methodSelectors).hasSize(2);
assertThat(methodSelectors.get(0).getClassName()).isEqualTo("com.acme.Foo");
assertThat(methodSelectors.get(0).getMethodName()).isEqualTo("m");
assertThat(methodSelectors.get(0).getMethodParameterTypes()).isEqualTo("");
assertThat(methodSelectors.get(1).getClassName()).isEqualTo("com.example.Bar");
assertThat(methodSelectors.get(1).getMethodName()).isEqualTo("method");
assertThat(methodSelectors.get(1).getMethodParameterTypes()).isEqualTo("java.lang.Object");
}
use of org.junit.platform.engine.discovery.MethodSelector in project junit5 by junit-team.
the class TestClassWithTemplate method methodResolutionFromInheritedMethod.
@Test
void methodResolutionFromInheritedMethod() throws NoSuchMethodException {
MethodSelector selector = selectMethod(HerTestClass.class, MyTestClass.class.getDeclaredMethod("test1"));
resolver.resolveSelectors(request().selectors(selector).build(), engineDescriptor);
assertEquals(2, engineDescriptor.getDescendants().size());
List<UniqueId> uniqueIds = uniqueIds();
assertThat(uniqueIds).contains(uniqueIdForClass(HerTestClass.class));
assertThat(uniqueIds).contains(uniqueIdForMethod(HerTestClass.class, "test1()"));
}
use of org.junit.platform.engine.discovery.MethodSelector in project junit5 by junit-team.
the class TestClassWithTemplate method methodResolutionInDoubleNestedTestClass.
@Test
void methodResolutionInDoubleNestedTestClass() throws NoSuchMethodException {
MethodSelector selector = selectMethod(TestCaseWithNesting.NestedTestCase.DoubleNestedTestCase.class, TestCaseWithNesting.NestedTestCase.DoubleNestedTestCase.class.getDeclaredMethod("testC"));
resolver.resolveSelectors(request().selectors(selector).build(), engineDescriptor);
assertEquals(4, engineDescriptor.getDescendants().size());
List<UniqueId> uniqueIds = uniqueIds();
assertThat(uniqueIds).contains(uniqueIdForClass(TestCaseWithNesting.class));
assertThat(uniqueIds).contains(uniqueIdForClass(TestCaseWithNesting.NestedTestCase.class));
assertThat(uniqueIds).contains(uniqueIdForClass(TestCaseWithNesting.NestedTestCase.DoubleNestedTestCase.class));
assertThat(uniqueIds).contains(uniqueIdForMethod(TestCaseWithNesting.NestedTestCase.DoubleNestedTestCase.class, "testC()"));
}
Aggregations