Search in sources :

Example 41 with EngineExecutionResults

use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.

the class TestTemplateInvocationTests method templateWithSupportingProviderButNoInvocationsReportsFailure.

@Test
void templateWithSupportingProviderButNoInvocationsReportsFailure() {
    LauncherDiscoveryRequest request = request().selectors(selectMethod(MyTestTemplateTestCase.class, "templateWithSupportingProviderButNoInvocations")).build();
    EngineExecutionResults executionResults = executeTests(request);
    // 
    executionResults.allEvents().assertEventsMatchExactly(wrappedInContainerEvents(// 
    MyTestTemplateTestCase.class, // 
    event(container("templateWithSupportingProviderButNoInvocations"), started()), event(container("templateWithSupportingProviderButNoInvocations"), finishedWithFailure(message("None of the supporting TestTemplateInvocationContextProviders [" + InvocationContextProviderThatSupportsEverythingButProvidesNothing.class.getSimpleName() + "] provided a non-empty stream")))));
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) Test(org.junit.jupiter.api.Test)

Example 42 with EngineExecutionResults

use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.

the class TestTemplateInvocationTests method templateWithTwoRegisteredExtensionsIsInvoked.

@Test
void templateWithTwoRegisteredExtensionsIsInvoked() {
    LauncherDiscoveryRequest request = request().selectors(selectMethod(MyTestTemplateTestCase.class, "templateWithTwoRegisteredExtensions")).build();
    EngineExecutionResults executionResults = executeTests(request);
    // 
    executionResults.allEvents().assertEventsMatchExactly(wrappedInContainerEvents(// 
    MyTestTemplateTestCase.class, // 
    event(container("templateWithTwoRegisteredExtensions"), 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("templateWithTwoRegisteredExtensions"), finishedSuccessfully())));
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) Test(org.junit.jupiter.api.Test)

Example 43 with EngineExecutionResults

use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.

the class TestTemplateInvocationTests method disabledTemplateIsSkipped.

@Test
void disabledTemplateIsSkipped() {
    LauncherDiscoveryRequest request = request().selectors(selectMethod(MyTestTemplateTestCase.class, "disabledTemplate")).build();
    EngineExecutionResults executionResults = executeTests(request);
    // 
    executionResults.allEvents().assertEventsMatchExactly(wrappedInContainerEvents(// 
    MyTestTemplateTestCase.class, event(container("disabledTemplate"), skippedWithReason("always disabled"))));
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) Test(org.junit.jupiter.api.Test)

Example 44 with EngineExecutionResults

use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.

the class TestTemplateInvocationTests method templateWithCustomizedDisplayNamesIsInvoked.

@Test
void templateWithCustomizedDisplayNamesIsInvoked() {
    LauncherDiscoveryRequest request = request().selectors(selectMethod(MyTestTemplateTestCase.class, "templateWithCustomizedDisplayNames")).build();
    EngineExecutionResults executionResults = executeTests(request);
    // 
    executionResults.allEvents().assertEventsMatchExactly(wrappedInContainerEvents(// 
    MyTestTemplateTestCase.class, // 
    event(container("templateWithCustomizedDisplayNames"), started()), event(dynamicTestRegistered("test-template-invocation:#1"), // 
    displayName("1 --> templateWithCustomizedDisplayNames()")), // 
    event(test("test-template-invocation:#1"), started()), event(test("test-template-invocation:#1"), // 
    finishedWithFailure(message("invocation is expected to fail"))), event(container("templateWithCustomizedDisplayNames"), finishedSuccessfully())));
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) Test(org.junit.jupiter.api.Test)

Example 45 with EngineExecutionResults

use of org.junit.platform.testkit.engine.EngineExecutionResults in project junit5 by junit-team.

the class ExceptionHandlingTests method checkedExceptionInAfterAllIsRegistered.

@Test
void checkedExceptionInAfterAllIsRegistered() {
    Class<?> testClass = FailureTestCase.class;
    FailureTestCase.exceptionToThrowInAfterAll = Optional.of(new IOException("checked"));
    EngineExecutionResults executionResults = executeTests(selectMethod(testClass, "succeedingTest"));
    // 
    executionResults.allEvents().assertEventsMatchExactly(// 
    event(engine(), started()), // 
    event(container(testClass), started()), // 
    event(test("succeedingTest"), started()), // 
    event(test("succeedingTest"), finishedSuccessfully()), // 
    event(container(testClass), finishedWithFailure(instanceOf(IOException.class), message("checked"))), event(engine(), finishedSuccessfully()));
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) IOException(java.io.IOException) Test(org.junit.jupiter.api.Test)

Aggregations

EngineExecutionResults (org.junit.platform.testkit.engine.EngineExecutionResults)139 Test (org.junit.jupiter.api.Test)134 LauncherDiscoveryRequest (org.junit.platform.launcher.LauncherDiscoveryRequest)32 DynamicTest (org.junit.jupiter.api.DynamicTest)30 DynamicTest.dynamicTest (org.junit.jupiter.api.DynamicTest.dynamicTest)30 Events (org.junit.platform.testkit.engine.Events)27 DisplayName (org.junit.jupiter.api.DisplayName)15 RepeatedTest (org.junit.jupiter.api.RepeatedTest)15 IOException (java.io.IOException)12 Execution (org.junit.platform.testkit.engine.Execution)12 TimeoutException (java.util.concurrent.TimeoutException)10 List (java.util.List)8 ExtensionConfigurationException (org.junit.jupiter.api.extension.ExtensionConfigurationException)8 ArrayList (java.util.ArrayList)7 AfterAll (org.junit.jupiter.api.AfterAll)7 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)7 BeforeAll (org.junit.jupiter.api.BeforeAll)7 BeforeEach (org.junit.jupiter.api.BeforeEach)7 Nested (org.junit.jupiter.api.Nested)7 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)7