Search in sources :

Example 86 with ExecutionEventRecorder

use of org.junit.platform.engine.test.event.ExecutionEventRecorder in project junit5 by junit-team.

the class ExceptionHandlingTests method checkedExceptionInTestMethodIsRegistered.

@Test
void checkedExceptionInTestMethodIsRegistered() throws NoSuchMethodException {
    Method method = FailureTestCase.class.getDeclaredMethod("testWithCheckedException");
    LauncherDiscoveryRequest request = request().selectors(selectMethod(FailureTestCase.class, method)).build();
    ExecutionEventRecorder eventRecorder = executeTests(request);
    assertEquals(1, eventRecorder.getTestStartedCount(), "# tests started");
    assertEquals(1, eventRecorder.getTestFailedCount(), "# tests failed");
    assertRecordedExecutionEventsContainsExactly(// 
    eventRecorder.getFailedTestFinishedEvents(), event(test("testWithCheckedException"), finishedWithFailure(allOf(isA(IOException.class), message("checked")))));
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) ExecutionEventRecorder(org.junit.platform.engine.test.event.ExecutionEventRecorder) DiscoverySelectors.selectMethod(org.junit.platform.engine.discovery.DiscoverySelectors.selectMethod) Method(java.lang.reflect.Method) Test(org.junit.jupiter.api.Test)

Example 87 with ExecutionEventRecorder

use of org.junit.platform.engine.test.event.ExecutionEventRecorder in project junit5 by junit-team.

the class InvalidLifecycleMethodConfigurationTests method assertExecutionResults.

private void assertExecutionResults(Class<?> invalidTestClass) {
    LauncherDiscoveryRequest request = request().selectors(selectClass(TestCase.class), selectClass(invalidTestClass)).build();
    ExecutionEventRecorder eventRecorder = executeTests(request);
    // @formatter:off
    assertAll(() -> assertEquals(3, eventRecorder.getContainerStartedCount(), "# containers started"), () -> assertEquals(1, eventRecorder.getTestStartedCount(), "# tests started"), () -> assertEquals(1, eventRecorder.getTestSuccessfulCount(), "# tests succeeded"), () -> assertEquals(0, eventRecorder.getTestFailedCount(), "# tests failed"), () -> assertEquals(3, eventRecorder.getContainerFinishedCount(), "# containers finished"), () -> assertEquals(1, eventRecorder.getContainerFailedCount(), "# containers failed"));
// @formatter:on
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) ExecutionEventRecorder(org.junit.platform.engine.test.event.ExecutionEventRecorder)

Example 88 with ExecutionEventRecorder

use of org.junit.platform.engine.test.event.ExecutionEventRecorder in project junit5 by junit-team.

the class NestedTestClassesTests method inheritedNestedTestsAreExecuted.

@Test
void inheritedNestedTestsAreExecuted() {
    ExecutionEventRecorder eventRecorder = executeTestsForClass(TestCaseWithInheritedNested.class);
    assertEquals(2, eventRecorder.getTestStartedCount(), "# tests started");
    assertEquals(1, eventRecorder.getTestSuccessfulCount(), "# tests succeeded");
    assertEquals(1, eventRecorder.getTestFailedCount(), "# tests failed");
    assertEquals(3, eventRecorder.getContainerStartedCount(), "# containers started");
    assertEquals(3, eventRecorder.getContainerFinishedCount(), "# containers finished");
}
Also used : ExecutionEventRecorder(org.junit.platform.engine.test.event.ExecutionEventRecorder) Test(org.junit.jupiter.api.Test)

Example 89 with ExecutionEventRecorder

use of org.junit.platform.engine.test.event.ExecutionEventRecorder in project junit5 by junit-team.

the class AbstractJupiterTestEngineTests method executeTests.

protected ExecutionEventRecorder executeTests(LauncherDiscoveryRequest request) {
    TestDescriptor testDescriptor = discoverTests(request);
    ExecutionEventRecorder eventRecorder = new ExecutionEventRecorder();
    engine.execute(new ExecutionRequest(testDescriptor, eventRecorder, request.getConfigurationParameters()));
    return eventRecorder;
}
Also used : ExecutionEventRecorder(org.junit.platform.engine.test.event.ExecutionEventRecorder) ExecutionRequest(org.junit.platform.engine.ExecutionRequest) TestDescriptor(org.junit.platform.engine.TestDescriptor)

Example 90 with ExecutionEventRecorder

use of org.junit.platform.engine.test.event.ExecutionEventRecorder in project junit5 by junit-team.

the class BeforeAllAndAfterAllComposedAnnotationTests method beforeAllAndAfterAllAsMetaAnnotations.

@Test
void beforeAllAndAfterAllAsMetaAnnotations() {
    ExecutionEventRecorder eventRecorder = executeTestsForClass(TestCase.class);
    assertEquals(1, eventRecorder.getTestStartedCount(), "# tests started");
    assertEquals(1, eventRecorder.getTestSuccessfulCount(), "# tests succeeded");
    assertEquals(asList("beforeAll", "test", "afterAll"), methodsInvoked);
}
Also used : ExecutionEventRecorder(org.junit.platform.engine.test.event.ExecutionEventRecorder) Test(org.junit.jupiter.api.Test)

Aggregations

ExecutionEventRecorder (org.junit.platform.engine.test.event.ExecutionEventRecorder)114 Test (org.junit.jupiter.api.Test)104 LauncherDiscoveryRequest (org.junit.platform.launcher.LauncherDiscoveryRequest)74 DynamicTest (org.junit.jupiter.api.DynamicTest)12 DynamicTest.dynamicTest (org.junit.jupiter.api.DynamicTest.dynamicTest)12 DiscoverySelectors.selectMethod (org.junit.platform.engine.discovery.DiscoverySelectors.selectMethod)12 Method (java.lang.reflect.Method)10 TestDescriptor (org.junit.platform.engine.TestDescriptor)8 IOException (java.io.IOException)6 DiscoverySelectors.selectUniqueId (org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId)5 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)4 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)4 TestInfo (org.junit.jupiter.api.TestInfo)4 UniqueId (org.junit.platform.engine.UniqueId)4 JupiterTestEngine (org.junit.jupiter.engine.JupiterTestEngine)3 LauncherDiscoveryRequestBuilder.request (org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder.request)3 Map (java.util.Map)2 Optional (java.util.Optional)2 Predicate (java.util.function.Predicate)2 Assertions.allOf (org.assertj.core.api.Assertions.allOf)2