use of org.junit.platform.launcher.LauncherDiscoveryRequest in project junit5 by junit-team.
the class DiscoveryRequestCreatorTests method convertsExcludeClassNamePatternOption.
@Test
void convertsExcludeClassNamePatternOption() {
options.setScanClasspath(true);
options.setExcludedClassNamePatterns(asList("Foo.*Bar", "Bar.*Foo"));
LauncherDiscoveryRequest request = convert();
List<ClassNameFilter> filter = request.getFiltersByType(ClassNameFilter.class);
assertThat(filter).hasSize(2);
assertThat(filter.get(1).toString()).contains("Foo.*Bar");
assertThat(filter.get(1).toString()).contains("Bar.*Foo");
}
use of org.junit.platform.launcher.LauncherDiscoveryRequest in project junit5 by junit-team.
the class LauncherFactoryTests method create.
@Test
void create() {
LauncherDiscoveryRequest discoveryRequest = createLauncherDiscoveryRequestForBothStandardEngineExampleClasses();
TestPlan testPlan = LauncherFactory.create().discover(discoveryRequest);
Set<TestIdentifier> roots = testPlan.getRoots();
assertThat(roots).hasSize(2);
// @formatter:off
List<String> ids = roots.stream().map(TestIdentifier::getUniqueId).collect(toList());
// @formatter:on
assertThat(ids).containsOnly("[engine:junit-vintage]", "[engine:junit-jupiter]");
}
use of org.junit.platform.launcher.LauncherDiscoveryRequest in project junit5 by junit-team.
the class TestExecutionExceptionHandlerTests method exceptionHandlerConvertsException.
@Test
void exceptionHandlerConvertsException() {
LauncherDiscoveryRequest request = request().selectors(selectMethod(ATestCase.class, "testConvert")).build();
ExecutionEventRecorder eventRecorder = executeTests(request);
assertTrue(ConvertException.handleExceptionCalled, "TestExecutionExceptionHandler should have been called");
assertRecordedExecutionEventsContainsExactly(//
eventRecorder.getExecutionEvents(), //
event(engine(), started()), //
event(container(ATestCase.class), started()), //
event(test("testConvert"), started()), //
event(test("testConvert"), finishedWithFailure(allOf(isA(IOException.class), message("checked")))), //
event(container(ATestCase.class), finishedSuccessfully()), event(engine(), finishedSuccessfully()));
}
use of org.junit.platform.launcher.LauncherDiscoveryRequest in project junit5 by junit-team.
the class TestExecutionExceptionHandlerTests method exceptionHandlerRethrowsException.
@Test
void exceptionHandlerRethrowsException() {
LauncherDiscoveryRequest request = request().selectors(selectMethod(ATestCase.class, "testRethrow")).build();
ExecutionEventRecorder eventRecorder = executeTests(request);
assertTrue(RethrowException.handleExceptionCalled, "TestExecutionExceptionHandler should have been called");
assertRecordedExecutionEventsContainsExactly(//
eventRecorder.getExecutionEvents(), //
event(engine(), started()), //
event(container(ATestCase.class), started()), //
event(test("testRethrow"), started()), //
event(test("testRethrow"), finishedWithFailure(allOf(isA(IOException.class), message("checked")))), //
event(container(ATestCase.class), finishedSuccessfully()), event(engine(), finishedSuccessfully()));
}
use of org.junit.platform.launcher.LauncherDiscoveryRequest in project junit5 by junit-team.
the class BeforeAndAfterEachTests method beforeEachCallbackThrowsAnException.
@Test
void beforeEachCallbackThrowsAnException() {
LauncherDiscoveryRequest request = request().selectors(selectClass(ExceptionInBeforeEachCallbackTestCase.class)).build();
ExecutionEventRecorder eventRecorder = executeTests(request);
assertEquals(1, eventRecorder.getTestStartedCount(), "# tests started");
assertEquals(0, eventRecorder.getTestSuccessfulCount(), "# tests succeeded");
assertEquals(0, eventRecorder.getTestSkippedCount(), "# tests skipped");
assertEquals(0, eventRecorder.getTestAbortedCount(), "# tests aborted");
assertEquals(1, eventRecorder.getTestFailedCount(), "# tests failed");
// @formatter:off
assertEquals(asList("fooBeforeEachCallback", // throws an exception.
"exceptionThrowingBeforeEachCallback", // afterEachMethod should not get invoked.
"barAfterEachCallback", "fooAfterEachCallback"), callSequence, "wrong call sequence");
// @formatter:on
assertThat(actualExceptionInAfterEachCallback).containsInstanceOf(EnigmaException.class);
}
Aggregations