use of org.junit.platform.engine.ConfigurationParameters in project junit5 by junit-team.
the class LauncherConfigurationParametersTests method explicitConfigParamOverridesSystemProperty.
@Test
void explicitConfigParamOverridesSystemProperty() {
System.setProperty(KEY, SYSTEM_PROPERTY);
ConfigurationParameters configParams = fromMap(singletonMap(KEY, CONFIG_PARAM));
assertThat(configParams.get(KEY)).contains(CONFIG_PARAM);
assertThat(configParams.toString()).contains(CONFIG_PARAM);
}
use of org.junit.platform.engine.ConfigurationParameters in project junit5 by junit-team.
the class ExtensionContextTests method configurationParameter.
@TestFactory
Stream<DynamicTest> configurationParameter() throws Exception {
ConfigurationParameters echo = new EchoParameters();
String key = "123";
Optional<String> expected = Optional.of(key);
UniqueId engineUniqueId = UniqueId.parse("[engine:junit-jupiter]");
JupiterEngineDescriptor engineDescriptor = new JupiterEngineDescriptor(engineUniqueId);
UniqueId classUniqueId = UniqueId.parse("[engine:junit-jupiter]/[class:MyClass]");
ClassTestDescriptor classTestDescriptor = new ClassTestDescriptor(classUniqueId, getClass());
Method method = getClass().getDeclaredMethod("configurationParameter");
UniqueId methodUniqueId = UniqueId.parse("[engine:junit-jupiter]/[class:MyClass]/[method:myMethod]");
TestMethodTestDescriptor methodTestDescriptor = new TestMethodTestDescriptor(methodUniqueId, getClass(), method);
return //
Stream.of(//
(ExtensionContext) new JupiterEngineExtensionContext(null, engineDescriptor, echo), //
new ClassExtensionContext(null, null, classTestDescriptor, echo, null), //
new MethodExtensionContext(null, null, methodTestDescriptor, echo, null, null)).map(context -> dynamicTest(context.getClass().getSimpleName(), () -> assertEquals(expected, context.getConfigurationParameter(key))));
}
use of org.junit.platform.engine.ConfigurationParameters in project junit5 by junit-team.
the class TestInstanceLifecycleUtilsTests method getTestInstanceLifecycleWithConfigParamSet.
@Test
void getTestInstanceLifecycleWithConfigParamSet() {
ConfigurationParameters configParams = mock(ConfigurationParameters.class);
when(configParams.get(KEY)).thenReturn(Optional.of(PER_CLASS.name().toLowerCase()));
Lifecycle lifecycle = getTestInstanceLifecycle(getClass(), configParams);
assertThat(lifecycle).isEqualTo(PER_CLASS);
}
use of org.junit.platform.engine.ConfigurationParameters in project junit5 by junit-team.
the class DiscoveryRequestCreatorTests method convertsConfigurationParameters.
@Test
void convertsConfigurationParameters() {
options.setScanClasspath(true);
options.setConfigurationParameters(mapOf(entry("foo", "bar"), entry("baz", "true")));
LauncherDiscoveryRequest request = convert();
ConfigurationParameters configurationParameters = request.getConfigurationParameters();
assertThat(configurationParameters.size()).isEqualTo(2);
assertThat(configurationParameters.get("foo")).contains("bar");
assertThat(configurationParameters.getBoolean("baz")).contains(true);
}
use of org.junit.platform.engine.ConfigurationParameters in project junit5 by junit-team.
the class TestInstanceLifecycleUtilsTests method assertDefaultConfigParam.
private void assertDefaultConfigParam(String configValue, Lifecycle expected) {
ConfigurationParameters configParams = mock(ConfigurationParameters.class);
when(configParams.get(KEY)).thenReturn(Optional.ofNullable(configValue));
Lifecycle lifecycle = getDefaultTestInstanceLifecycle(configParams);
assertThat(lifecycle).isEqualTo(expected);
}
Aggregations