use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class TestTemplateInvocationTests method legacyReportingNames.
@Test
void legacyReportingNames() {
LauncherDiscoveryRequest request = request().selectors(selectMethod(MyTestTemplateTestCase.class, "templateWithTwoRegisteredExtensions")).build();
EngineExecutionResults results = executeTests(request);
Events events = results.allEvents();
events.assertStatistics(stats -> stats.dynamicallyRegistered(2));
// events.dynamicallyRegistered().debug();
// results.testEvents().dynamicallyRegistered().debug();
// results.containerEvents().dynamicallyRegistered().debug();
// @formatter:off
Stream<String> legacyReportingNames = events.dynamicallyRegistered().map(Event::getTestDescriptor).map(TestDescriptor::getLegacyReportingName);
// @formatter:off
assertThat(legacyReportingNames).containsExactly("templateWithTwoRegisteredExtensions()[1]", "templateWithTwoRegisteredExtensions()[2]");
}
use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class TestTemplateInvocationTests method templateWithTwoInvocationsFromSingleExtensionIsInvoked.
@Test
void templateWithTwoInvocationsFromSingleExtensionIsInvoked() {
LauncherDiscoveryRequest request = request().selectors(selectMethod(MyTestTemplateTestCase.class, "templateWithTwoInvocationsFromSingleExtension")).build();
EngineExecutionResults executionResults = executeTests(request);
//
executionResults.allEvents().assertEventsMatchExactly(wrappedInContainerEvents(//
MyTestTemplateTestCase.class, //
event(container("templateWithTwoInvocationsFromSingleExtension"), started()), //
event(dynamicTestRegistered("test-template-invocation:#1"), displayName("[1]")), //
event(test("test-template-invocation:#1"), started()), event(test("test-template-invocation:#1"), //
finishedWithFailure(message("invocation is expected to fail"))), //
event(dynamicTestRegistered("test-template-invocation:#2"), displayName("[2]")), //
event(test("test-template-invocation:#2"), started()), event(test("test-template-invocation:#2"), //
finishedWithFailure(message("invocation is expected to fail"))), event(container("templateWithTwoInvocationsFromSingleExtension"), finishedSuccessfully())));
}
use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class TestTemplateInvocationTests method singleInvocationIsExecutedWhenDiscoveredByUniqueId.
@Test
void singleInvocationIsExecutedWhenDiscoveredByUniqueId() {
UniqueId uniqueId = discoverUniqueId(MyTestTemplateTestCase.class, //
"templateWithTwoInvocationsFromSingleExtension").append(TestTemplateInvocationTestDescriptor.SEGMENT_TYPE, "#2");
EngineExecutionResults executionResults = executeTests(selectUniqueId(uniqueId));
//
executionResults.allEvents().assertEventsMatchExactly(wrappedInContainerEvents(//
MyTestTemplateTestCase.class, //
event(container("templateWithTwoInvocationsFromSingleExtension"), started()), //
event(dynamicTestRegistered("test-template-invocation:#2"), displayName("[2]")), //
event(test("test-template-invocation:#2"), started()), event(test("test-template-invocation:#2"), //
finishedWithFailure(message("invocation is expected to fail"))), event(container("templateWithTwoInvocationsFromSingleExtension"), finishedSuccessfully())));
}
use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class TestTemplateInvocationTests method contextParameterResolverCanResolveConstructorArguments.
@Test
void contextParameterResolverCanResolveConstructorArguments() {
LauncherDiscoveryRequest request = request().selectors(selectMethod(MyTestTemplateTestCaseWithConstructor.class, "template", "java.lang.String")).build();
EngineExecutionResults executionResults = executeTests(request);
//
executionResults.allEvents().assertEventsMatchExactly(wrappedInContainerEvents(//
MyTestTemplateTestCase.class, //
event(container("template"), started()), //
event(dynamicTestRegistered("test-template-invocation:#1"), displayName("[1] foo")), //
event(test("test-template-invocation:#1"), started()), //
event(test("test-template-invocation:#1"), finishedSuccessfully()), //
event(dynamicTestRegistered("test-template-invocation:#2"), displayName("[2] bar")), //
event(test("test-template-invocation:#2"), started()), //
event(test("test-template-invocation:#2"), finishedSuccessfully()), event(container("template"), finishedSuccessfully())));
}
use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.
the class TestTemplateInvocationTests method extensionIsAskedForSupportBeforeItMustProvide.
@Test
void extensionIsAskedForSupportBeforeItMustProvide() {
LauncherDiscoveryRequest request = request().selectors(selectMethod(MyTestTemplateTestCase.class, "templateWithWrongParameterType", int.class.getName())).build();
EngineExecutionResults executionResults = executeTests(request);
//
executionResults.allEvents().assertEventsMatchExactly(wrappedInContainerEvents(//
MyTestTemplateTestCase.class, //
event(container("templateWithWrongParameterType"), started()), event(container("templateWithWrongParameterType"), finishedWithFailure(message(s -> s.startsWith("You must register at least one TestTemplateInvocationContextProvider that supports @TestTemplate method ["))))));
}
Aggregations