use of org.junit.platform.engine.ConfigurationParameters in project junit5 by junit-team.
the class TestInstanceLifecycleUtilsTests method getTestInstanceLifecycleWithLocalConfigThatOverridesCustomDefaultSetViaConfigParam.
@Test
void getTestInstanceLifecycleWithLocalConfigThatOverridesCustomDefaultSetViaConfigParam() {
ConfigurationParameters configParams = mock(ConfigurationParameters.class);
when(configParams.get(KEY)).thenReturn(Optional.of(PER_CLASS.name().toLowerCase()));
Lifecycle lifecycle = getTestInstanceLifecycle(TestCase.class, configParams);
assertThat(lifecycle).isEqualTo(PER_METHOD);
}
use of org.junit.platform.engine.ConfigurationParameters in project junit5 by junit-team.
the class DefaultLauncherTests method withConfigurationParameters_launcherPassesPopulatedConfigurationParametersIntoTheExecutionRequest.
@Test
void withConfigurationParameters_launcherPassesPopulatedConfigurationParametersIntoTheExecutionRequest() {
TestEngineSpy engine = new TestEngineSpy();
DefaultLauncher launcher = createLauncher(engine);
launcher.execute(request().configurationParameter("key", "value").build());
ConfigurationParameters configurationParameters = engine.requestForExecution.getConfigurationParameters();
assertThat(configurationParameters.size()).isEqualTo(1);
assertThat(configurationParameters.get("key").isPresent()).isTrue();
assertThat(configurationParameters.get("key").get()).isEqualTo("value");
}
use of org.junit.platform.engine.ConfigurationParameters 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);
}
}
use of org.junit.platform.engine.ConfigurationParameters in project junit5 by junit-team.
the class LauncherConfigurationParametersTests method systemProperty.
@Test
void systemProperty() {
System.setProperty(KEY, SYSTEM_PROPERTY);
ConfigurationParameters configParams = fromMap(emptyMap());
assertThat(configParams.get(KEY)).contains(SYSTEM_PROPERTY);
assertThat(configParams.toString()).doesNotContain(KEY);
}
use of org.junit.platform.engine.ConfigurationParameters in project junit5 by junit-team.
the class LauncherConfigurationParametersTests method getPreconditions.
@Test
void getPreconditions() {
ConfigurationParameters configParams = fromMap(emptyMap());
assertThrows(PreconditionViolationException.class, () -> configParams.get(null));
assertThrows(PreconditionViolationException.class, () -> configParams.get(""));
assertThrows(PreconditionViolationException.class, () -> configParams.get(" "));
}
Aggregations