use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class ParameterResolverTests method executeTestsForMethodInjectionInBeforeAndAfterAllMethods.
@Test
void executeTestsForMethodInjectionInBeforeAndAfterAllMethods() {
EngineExecutionResults executionResults = executeTestsForClass(BeforeAndAfterAllMethodInjectionTestCase.class);
assertEquals(1, executionResults.testEvents().started().count(), "# tests started");
assertEquals(1, executionResults.testEvents().succeeded().count(), "# tests succeeded");
assertEquals(0, executionResults.testEvents().skipped().count(), "# tests skipped");
assertEquals(0, executionResults.testEvents().aborted().count(), "# tests aborted");
assertEquals(0, executionResults.testEvents().failed().count(), "# tests failed");
}
use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class ParameterResolverTests method executeTestsForPrimitiveArrayMethodInjectionCases.
@Test
void executeTestsForPrimitiveArrayMethodInjectionCases() {
EngineExecutionResults executionResults = executeTestsForClass(PrimitiveArrayMethodInjectionTestCase.class);
assertEquals(1, executionResults.testEvents().started().count(), "# tests started");
assertEquals(1, executionResults.testEvents().succeeded().count(), "# tests succeeded");
assertEquals(0, executionResults.testEvents().failed().count(), "# tests failed");
}
use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class ParameterResolverTests method executeTestsForPotentiallyIncompatibleTypeMethodInjectionCases.
@Test
void executeTestsForPotentiallyIncompatibleTypeMethodInjectionCases() {
EngineExecutionResults executionResults = executeTestsForClass(PotentiallyIncompatibleTypeMethodInjectionTestCase.class);
Events tests = executionResults.testEvents();
assertEquals(3, executionResults.testEvents().started().count(), "# tests started");
assertEquals(2, executionResults.testEvents().succeeded().count(), "# tests succeeded");
assertEquals(1, executionResults.testEvents().failed().count(), "# tests failed");
// @formatter:off
Predicate<String> expectations = s -> s.contains("NumberParameterResolver") && s.contains("resolved a value of type [java.lang.Integer]") && s.contains("but a value assignment compatible with [java.lang.Double] is required");
tests.failed().assertEventsMatchExactly(event(test("doubleParameterInjection"), finishedWithFailure(instanceOf(ParameterResolutionException.class), message(expectations))));
// @formatter:on
}
use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class TempDirectoryParameterResolverTests method testTempDirType.
@Test
@DisplayName("Test good and bad @TempDir parameters")
void testTempDirType() {
EngineExecutionResults executionResults = executeTestsForClass(ATestCase.class);
Events tests = executionResults.testEvents();
tests.assertStatistics(stats -> stats.started(2).failed(1).succeeded(1));
tests.succeeded().assertEventsMatchExactly(event(test("testGoodTempDirType"), finishedSuccessfully()));
tests.failed().assertEventsMatchExactly(event(test("testBadTempDirType"), finishedWithFailure(instanceOf(ParameterResolutionException.class), message("Failed to resolve parameter [java.lang.String badTempDir] in method [void org.junit.jupiter.engine.extension.TempDirectoryParameterResolverTests$ATestCase.testBadTempDirType(java.lang.String)]: Can only resolve @TempDir parameter of type java.nio.file.Path or java.io.File but was: java.lang.String"))));
}
use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class TestExecutionExceptionHandlerTests method exceptionHandlerConvertsException.
@Test
void exceptionHandlerConvertsException() {
LauncherDiscoveryRequest request = request().selectors(selectMethod(ATestCase.class, "testConvert")).build();
EngineExecutionResults executionResults = executeTests(request);
assertTrue(ConvertException.handleExceptionCalled, "TestExecutionExceptionHandler should have been called");
//
executionResults.allEvents().assertEventsMatchExactly(//
event(engine(), started()), //
event(container(ATestCase.class), started()), //
event(test("testConvert"), started()), //
event(test("testConvert"), finishedWithFailure(instanceOf(IOException.class), message("checked"))), //
event(container(ATestCase.class), finishedSuccessfully()), event(engine(), finishedSuccessfully()));
}
Aggregations