use of org.junit.jupiter.api.DisplayNameGenerator in project junit5 by junit-team.
the class InstantiatingConfigurationParameterConverterTests method shouldTrimAndInstantiateConfiguredClass.
@Test
void shouldTrimAndInstantiateConfiguredClass(LogRecordListener listener) {
ConfigurationParameters configurationParameters = mock(ConfigurationParameters.class);
String classNameWithSpaces = " " + CustomDisplayNameGenerator.class.getName() + " ";
when(configurationParameters.get(KEY)).thenReturn(Optional.of(classNameWithSpaces));
InstantiatingConfigurationParameterConverter<DisplayNameGenerator> converter = new InstantiatingConfigurationParameterConverter<>(DisplayNameGenerator.class, "display name generator");
DisplayNameGenerator displayNameGenerator = converter.get(configurationParameters, KEY).orElseThrow();
assertThat(displayNameGenerator).isInstanceOf(CustomDisplayNameGenerator.class);
assertExpectedLogMessage(listener, Level.CONFIG, "Using default display name generator " + "'org.junit.jupiter.engine.descriptor.CustomDisplayNameGenerator' set via the " + "'junit.jupiter.displayname.generator.default' configuration parameter.");
}
use of org.junit.jupiter.api.DisplayNameGenerator in project junit5 by junit-team.
the class DefaultJupiterConfigurationTests method shouldGetStandardAsDefaultDisplayNameGeneratorWithoutConfigParamSet.
@Test
void shouldGetStandardAsDefaultDisplayNameGeneratorWithoutConfigParamSet() {
ConfigurationParameters parameters = mock(ConfigurationParameters.class);
String key = Constants.DEFAULT_DISPLAY_NAME_GENERATOR_PROPERTY_NAME;
when(parameters.get(key)).thenReturn(Optional.empty());
JupiterConfiguration configuration = new DefaultJupiterConfiguration(parameters);
DisplayNameGenerator defaultDisplayNameGenerator = configuration.getDefaultDisplayNameGenerator();
assertThat(defaultDisplayNameGenerator).isInstanceOf(DisplayNameGenerator.Standard.class);
}
use of org.junit.jupiter.api.DisplayNameGenerator in project junit5 by junit-team.
the class DefaultJupiterConfigurationTests method shouldGetDefaultDisplayNameGeneratorWithConfigParamSet.
@Test
void shouldGetDefaultDisplayNameGeneratorWithConfigParamSet() {
ConfigurationParameters parameters = mock(ConfigurationParameters.class);
String key = Constants.DEFAULT_DISPLAY_NAME_GENERATOR_PROPERTY_NAME;
when(parameters.get(key)).thenReturn(Optional.of(CustomDisplayNameGenerator.class.getName()));
JupiterConfiguration configuration = new DefaultJupiterConfiguration(parameters);
DisplayNameGenerator defaultDisplayNameGenerator = configuration.getDefaultDisplayNameGenerator();
assertThat(defaultDisplayNameGenerator).isInstanceOf(CustomDisplayNameGenerator.class);
}
use of org.junit.jupiter.api.DisplayNameGenerator in project junit5 by junit-team.
the class InstantiatingConfigurationParameterConverterTests method shouldReturnEmptyOptionalIfConfigurationIsBlank.
@Test
void shouldReturnEmptyOptionalIfConfigurationIsBlank() {
ConfigurationParameters configurationParameters = mock(ConfigurationParameters.class);
when(configurationParameters.get(KEY)).thenReturn(Optional.of(""));
InstantiatingConfigurationParameterConverter<DisplayNameGenerator> converter = new InstantiatingConfigurationParameterConverter<>(DisplayNameGenerator.class, "display name generator");
Optional<DisplayNameGenerator> displayNameGenerator = converter.get(configurationParameters, KEY);
assertThat(displayNameGenerator).isEmpty();
}
Aggregations