Search in sources :

Example 6 with TestEngineSpy

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

the class DefaultLauncherTests method withoutConfigurationParameters_LookupFallsBackToSystemProperty.

@Test
void withoutConfigurationParameters_LookupFallsBackToSystemProperty() {
    System.setProperty(FOO, BAR);
    try {
        TestEngineSpy engine = new TestEngineSpy();
        DefaultLauncher launcher = createLauncher(engine);
        launcher.execute(request().build());
        ConfigurationParameters configurationParameters = engine.requestForExecution.getConfigurationParameters();
        assertThat(configurationParameters.size()).isEqualTo(0);
        Optional<String> optionalFoo = configurationParameters.get(FOO);
        assertTrue(optionalFoo.isPresent(), "foo should have been picked up via system property");
        assertEquals(BAR, optionalFoo.get(), "foo property");
    } finally {
        System.clearProperty(FOO);
    }
}
Also used : ConfigurationParameters(org.junit.platform.engine.ConfigurationParameters) TestEngineSpy(org.junit.platform.engine.test.TestEngineSpy) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)6 TestEngineSpy (org.junit.platform.engine.test.TestEngineSpy)6 ConfigurationParameters (org.junit.platform.engine.ConfigurationParameters)4 EngineDiscoveryRequest (org.junit.platform.engine.EngineDiscoveryRequest)2 EngineExecutionListener (org.junit.platform.engine.EngineExecutionListener)2 ExecutionRequest (org.junit.platform.engine.ExecutionRequest)2 TestDescriptor (org.junit.platform.engine.TestDescriptor)2 UniqueId (org.junit.platform.engine.UniqueId)2 DiscoverySelectors.selectUniqueId (org.junit.platform.engine.discovery.DiscoverySelectors.selectUniqueId)2 DemoHierarchicalTestDescriptor (org.junit.platform.engine.support.hierarchical.DemoHierarchicalTestDescriptor)2 TestDescriptorStub (org.junit.platform.engine.test.TestDescriptorStub)2 TestExecutionListener (org.junit.platform.launcher.TestExecutionListener)2 TestIdentifier (org.junit.platform.launcher.TestIdentifier)2 TestPlan (org.junit.platform.launcher.TestPlan)2 SummaryGeneratingListener (org.junit.platform.launcher.listeners.SummaryGeneratingListener)2 InOrder (org.mockito.InOrder)2 Optional (java.util.Optional)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)1 Assertions.assertThrows (org.junit.jupiter.api.Assertions.assertThrows)1