use of org.junit.platform.launcher.LauncherDiscoveryRequest in project junit5 by junit-team.
the class DiscoveryTests method discoverMethodByUniqueId.
@Test
void discoverMethodByUniqueId() {
LauncherDiscoveryRequest request = request().selectors(selectUniqueId(JupiterUniqueIdBuilder.uniqueIdForMethod(LocalTestCase.class, "test1()"))).build();
TestDescriptor engineDescriptor = discoverTests(request);
assertEquals(2, engineDescriptor.getDescendants().size(), "# resolved test descriptors");
}
use of org.junit.platform.launcher.LauncherDiscoveryRequest in project junit5 by junit-team.
the class DiscoveryTests method discoverMultipleMethodsOfSameClass.
@Test
void discoverMultipleMethodsOfSameClass() throws NoSuchMethodException {
LauncherDiscoveryRequest request = request().selectors(selectMethod(LocalTestCase.class, "test1"), selectMethod(LocalTestCase.class, "test2")).build();
TestDescriptor engineDescriptor = discoverTests(request);
assertThat(engineDescriptor.getChildren()).hasSize(1);
TestDescriptor classDescriptor = getOnlyElement(engineDescriptor.getChildren());
assertThat(classDescriptor.getChildren()).hasSize(2);
}
use of org.junit.platform.launcher.LauncherDiscoveryRequest in project junit5 by junit-team.
the class TestPlanScannerFilter method accept.
@Override
@SuppressWarnings("rawtypes")
public boolean accept(Class testClass) {
// @formatter:off
LauncherDiscoveryRequest discoveryRequest = request().selectors(selectClass(testClass)).filters(includeAndExcludeFilters).build();
// @formatter:on
TestPlan testPlan = launcher.discover(discoveryRequest);
return testPlan.containsTests();
}
use of org.junit.platform.launcher.LauncherDiscoveryRequest in project junit5 by junit-team.
the class DisabledTests method executeTestsWithDisabledTestClass.
@Test
void executeTestsWithDisabledTestClass() {
LauncherDiscoveryRequest request = request().selectors(selectClass(DisabledTestClassTestCase.class)).build();
ExecutionEventRecorder eventRecorder = executeTests(request);
assertEquals(1, eventRecorder.getContainerSkippedCount(), "# container skipped");
assertEquals(0, eventRecorder.getTestStartedCount(), "# tests started");
}
use of org.junit.platform.launcher.LauncherDiscoveryRequest in project junit5 by junit-team.
the class DisabledTests method executeTestsWithDisabledTestMethods.
@Test
void executeTestsWithDisabledTestMethods() throws Exception {
LauncherDiscoveryRequest request = request().selectors(selectClass(DisabledTestMethodsTestCase.class)).build();
ExecutionEventRecorder eventRecorder = executeTests(request);
assertEquals(1, eventRecorder.getTestStartedCount(), "# tests started");
assertEquals(1, eventRecorder.getTestSuccessfulCount(), "# tests succeeded");
assertEquals(1, eventRecorder.getTestSkippedCount(), "# tests skipped");
String method = DisabledTestMethodsTestCase.class.getDeclaredMethod("disabledTest").toString();
String reason = eventRecorder.getSkippedTestEvents().get(0).getPayload(String.class).get();
assertEquals(method + " is @Disabled", reason);
}
Aggregations