Search in sources :

Example 86 with EngineExecutionResults

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

the class ParameterResolverTests method executeTestsForMethodInjectionCases.

@Test
void executeTestsForMethodInjectionCases() {
    EngineExecutionResults executionResults = executeTestsForClass(MethodInjectionTestCase.class);
    assertEquals(7, executionResults.testEvents().started().count(), "# tests started");
    assertEquals(6, executionResults.testEvents().succeeded().count(), "# tests succeeded");
    assertEquals(0, executionResults.testEvents().skipped().count(), "# tests skipped");
    assertEquals(0, executionResults.testEvents().aborted().count(), "# tests aborted");
    assertEquals(1, executionResults.testEvents().failed().count(), "# tests failed");
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) Test(org.junit.jupiter.api.Test)

Example 87 with EngineExecutionResults

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

the class ParameterResolverTests method executeTestsForNullValuedMethodInjectionCases.

@Test
void executeTestsForNullValuedMethodInjectionCases() {
    EngineExecutionResults executionResults = executeTestsForClass(NullMethodInjectionTestCase.class);
    Events tests = executionResults.testEvents();
    assertEquals(2, executionResults.testEvents().started().count(), "# tests started");
    assertEquals(1, executionResults.testEvents().succeeded().count(), "# tests succeeded");
    assertEquals(1, executionResults.testEvents().failed().count(), "# tests failed");
    // @formatter:off
    Predicate<String> expectations = s -> s.contains("NullIntegerParameterResolver") && s.contains("resolved a null value for parameter") && s.contains("but a primitive of type [int] is required");
    tests.failed().assertEventsMatchExactly(event(test("injectPrimitive"), finishedWithFailure(instanceOf(ParameterResolutionException.class), message(expectations))));
// @formatter:on
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) DiscoverySelectors.selectMethod(org.junit.platform.engine.discovery.DiscoverySelectors.selectMethod) BeforeEach(org.junit.jupiter.api.BeforeEach) CustomTypeParameterResolver(org.junit.jupiter.engine.execution.injection.sample.CustomTypeParameterResolver) Events(org.junit.platform.testkit.engine.Events) EventConditions.event(org.junit.platform.testkit.engine.EventConditions.event) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) EventConditions.finishedWithFailure(org.junit.platform.testkit.engine.EventConditions.finishedWithFailure) CustomType(org.junit.jupiter.engine.execution.injection.sample.CustomType) NumberParameterResolver(org.junit.jupiter.engine.execution.injection.sample.NumberParameterResolver) TestExecutionResultConditions.message(org.junit.platform.testkit.engine.TestExecutionResultConditions.message) Disabled(org.junit.jupiter.api.Disabled) Nested(org.junit.jupiter.api.Nested) JupiterTestEngine(org.junit.jupiter.engine.JupiterTestEngine) AfterAll(org.junit.jupiter.api.AfterAll) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) CustomAnnotationParameterResolver(org.junit.jupiter.engine.execution.injection.sample.CustomAnnotationParameterResolver) BeforeAll(org.junit.jupiter.api.BeforeAll) AbstractJupiterTestEngineTests(org.junit.jupiter.engine.AbstractJupiterTestEngineTests) PrimitiveArrayParameterResolver(org.junit.jupiter.engine.execution.injection.sample.PrimitiveArrayParameterResolver) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) EventConditions.test(org.junit.platform.testkit.engine.EventConditions.test) MapOfListsTypeBasedParameterResolver(org.junit.jupiter.engine.execution.injection.sample.MapOfListsTypeBasedParameterResolver) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Method(java.lang.reflect.Method) EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) MapOfStringsParameterResolver(org.junit.jupiter.engine.execution.injection.sample.MapOfStringsParameterResolver) Predicate(java.util.function.Predicate) ParameterResolutionException(org.junit.jupiter.api.extension.ParameterResolutionException) PrimitiveIntegerParameterResolver(org.junit.jupiter.engine.execution.injection.sample.PrimitiveIntegerParameterResolver) ReflectionUtils(org.junit.platform.commons.util.ReflectionUtils) TestInfo(org.junit.jupiter.api.TestInfo) NullIntegerParameterResolver(org.junit.jupiter.engine.execution.injection.sample.NullIntegerParameterResolver) DisplayName(org.junit.jupiter.api.DisplayName) Assertions.assertArrayEquals(org.junit.jupiter.api.Assertions.assertArrayEquals) Test(org.junit.jupiter.api.Test) List(java.util.List) AfterEach(org.junit.jupiter.api.AfterEach) TestExecutionResultConditions.instanceOf(org.junit.platform.testkit.engine.TestExecutionResultConditions.instanceOf) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) CustomAnnotation(org.junit.jupiter.engine.execution.injection.sample.CustomAnnotation) ParameterResolver(org.junit.jupiter.api.extension.ParameterResolver) Events(org.junit.platform.testkit.engine.Events) ParameterResolutionException(org.junit.jupiter.api.extension.ParameterResolutionException) Test(org.junit.jupiter.api.Test)

Example 88 with EngineExecutionResults

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

the class ParameterResolverTests method constructorInjection.

@Test
void constructorInjection() {
    EngineExecutionResults executionResults = executeTestsForClass(ConstructorInjectionTestCase.class);
    assertEquals(2, executionResults.testEvents().started().count(), "# tests started");
    assertEquals(2, 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");
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) Test(org.junit.jupiter.api.Test)

Example 89 with EngineExecutionResults

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

the class ParameterResolverTests method executeTestsForMethodWithExtendWithAnnotation.

@Test
void executeTestsForMethodWithExtendWithAnnotation() {
    EngineExecutionResults executionResults = executeTestsForClass(ExtendWithOnMethodTestCase.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");
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) Test(org.junit.jupiter.api.Test)

Example 90 with EngineExecutionResults

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

the class TestWatcherTests method testWatcherIsNotInvokedForTestFactoryMethods.

@Test
void testWatcherIsNotInvokedForTestFactoryMethods() {
    EngineExecutionResults results = executeTestsForClass(TrackingTestWatcherTestFactoryMethodsTestCase.class);
    results.containerEvents().assertStatistics(stats -> stats.skipped(1).started(5).succeeded(5).aborted(0).failed(0));
    results.testEvents().assertStatistics(stats -> stats.dynamicallyRegistered(6).skipped(0).started(6).succeeded(2).aborted(2).failed(2));
    // There should be zero results, since the TestWatcher API is not supported for @TestFactory containers.
    assertThat(TrackingTestWatcher.results).isEmpty();
}
Also used : EngineExecutionResults(org.junit.platform.testkit.engine.EngineExecutionResults) RepeatedTest(org.junit.jupiter.api.RepeatedTest) DynamicTest.dynamicTest(org.junit.jupiter.api.DynamicTest.dynamicTest) Test(org.junit.jupiter.api.Test) DynamicTest(org.junit.jupiter.api.DynamicTest)

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