Search in sources :

Example 61 with ExecutionEventRecorder

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

the class DefaultMethodTests method executeTestCaseWithOverriddenGenericDefaultMethodSelectedByClass.

@Test
void executeTestCaseWithOverriddenGenericDefaultMethodSelectedByClass() throws Exception {
    Class<?> clazz = GenericTestCaseWithOverriddenDefaultMethod.class;
    LauncherDiscoveryRequest request = request().selectors(selectClass(clazz)).build();
    ExecutionEventRecorder eventRecorder = executeTests(request);
    // @formatter:off
    assertAll(() -> assertTrue(beforeAllInvoked, "@BeforeAll default method invoked from interface"), () -> assertTrue(afterAllInvoked, "@AfterAll default method invoked from interface"), () -> assertFalse(defaultMethodInvoked, "default @Test method should not have been invoked from interface"), () -> assertTrue(overriddenDefaultMethodInvoked, "overridden default @Test method invoked from interface"), () -> assertTrue(localMethodInvoked, "local @Test method invoked from class"), // should not have been "discovered" since it is overridden.
    () -> assertEquals(2, eventRecorder.getTestStartedCount(), "# tests started"), () -> assertEquals(2, eventRecorder.getTestSuccessfulCount(), "# tests succeeded"), () -> assertEquals(0, eventRecorder.getTestFailedCount(), "# tests failed"));
// @formatter:on
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) ExecutionEventRecorder(org.junit.platform.engine.test.event.ExecutionEventRecorder) Test(org.junit.jupiter.api.Test)

Example 62 with ExecutionEventRecorder

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

the class ReportingTests method threeReportEntriesArePublished.

@Test
void threeReportEntriesArePublished() {
    LauncherDiscoveryRequest request = request().selectors(selectClass(MyReportingTestCase.class)).build();
    ExecutionEventRecorder eventRecorder = executeTests(request);
    assertEquals(2, eventRecorder.getTestStartedCount(), "# tests started");
    assertEquals(2, eventRecorder.getTestSuccessfulCount(), "# tests succeeded");
    assertEquals(0, eventRecorder.getTestFailedCount(), "# tests failed");
    assertEquals(6, eventRecorder.getReportingEntryPublishedCount(), "# report entries published");
}
Also used : LauncherDiscoveryRequest(org.junit.platform.launcher.LauncherDiscoveryRequest) ExecutionEventRecorder(org.junit.platform.engine.test.event.ExecutionEventRecorder) Test(org.junit.jupiter.api.Test)

Example 63 with ExecutionEventRecorder

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

the class StandardTestClassTests method allTestsInClassAreRunWithAfterEach.

@Test
void allTestsInClassAreRunWithAfterEach() {
    ExecutionEventRecorder eventRecorder = executeTestsForClass(MyStandardTestCase.class);
    assertEquals(4, eventRecorder.getTestStartedCount(), "# tests started");
    assertEquals(4, MyStandardTestCase.countAfter, "# after each calls");
    assertEquals(2, eventRecorder.getContainerStartedCount(), "# containers started");
    assertEquals(2, eventRecorder.getContainerFinishedCount(), "# containers finished");
}
Also used : ExecutionEventRecorder(org.junit.platform.engine.test.event.ExecutionEventRecorder) Test(org.junit.jupiter.api.Test)

Example 64 with ExecutionEventRecorder

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

the class StandardTestClassTests method allTestsInClassAreRunWithBeforeEach.

@Test
void allTestsInClassAreRunWithBeforeEach() {
    ExecutionEventRecorder eventRecorder = executeTestsForClass(MyStandardTestCase.class);
    assertEquals(4, eventRecorder.getTestStartedCount(), "# tests started");
    assertEquals(2, eventRecorder.getTestSuccessfulCount(), "# tests succeeded");
    assertEquals(1, eventRecorder.getTestAbortedCount(), "# tests aborted");
    assertEquals(1, eventRecorder.getTestFailedCount(), "# tests failed");
    assertEquals(2, eventRecorder.getContainerStartedCount(), "# containers started");
    assertEquals(2, eventRecorder.getContainerFinishedCount(), "# containers finished");
    assertEquals(4, MyStandardTestCase.countBefore1, "# before1 calls");
    assertEquals(4, MyStandardTestCase.countBefore2, "# before2 calls");
}
Also used : ExecutionEventRecorder(org.junit.platform.engine.test.event.ExecutionEventRecorder) Test(org.junit.jupiter.api.Test)

Example 65 with ExecutionEventRecorder

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

the class TestCaseWithInheritanceTests method executeAllTestsInClass.

@Test
void executeAllTestsInClass() {
    ExecutionEventRecorder eventRecorder = executeTestsForClass(LocalTestCase.class);
    assertEquals(6, eventRecorder.getTestStartedCount(), "# tests started");
    assertEquals(3, eventRecorder.getTestSuccessfulCount(), "# tests succeeded");
    assertEquals(0, eventRecorder.getTestSkippedCount(), "# tests skipped");
    assertEquals(1, eventRecorder.getTestAbortedCount(), "# tests aborted");
    assertEquals(2, eventRecorder.getTestFailedCount(), "# tests failed");
    assertEquals(6, LocalTestCase.countBeforeInvoked, "# before calls");
    assertEquals(6, LocalTestCase.countAfterInvoked, "# after calls");
    assertEquals(6, AbstractTestCase.countSuperBeforeInvoked, "# super before calls");
    assertEquals(6, AbstractTestCase.countSuperAfterInvoked, "# super after calls");
}
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