use of org.junit.jupiter.engine.descriptor.CustomDisplayNameGenerator in project junit5 by junit-team.
the class CachingJupiterConfigurationTests method cachesDefaultDisplayNameGenerator.
@Test
void cachesDefaultDisplayNameGenerator() {
CustomDisplayNameGenerator customDisplayNameGenerator = new CustomDisplayNameGenerator();
when(delegate.getDefaultDisplayNameGenerator()).thenReturn(customDisplayNameGenerator);
// call `cache.getDefaultDisplayNameGenerator()` twice to verify the delegate method is called only once.
assertThat(cache.getDefaultDisplayNameGenerator()).isSameAs(customDisplayNameGenerator);
assertThat(cache.getDefaultDisplayNameGenerator()).isSameAs(customDisplayNameGenerator);
verify(delegate, only()).getDefaultDisplayNameGenerator();
}
use of org.junit.jupiter.engine.descriptor.CustomDisplayNameGenerator in project junit5 by junit-team.
the class InstantiatingConfigurationParameterConverterTests method shouldReturnEmptyOptionalIfClassNameIsNotFullyQualified.
@Test
void shouldReturnEmptyOptionalIfClassNameIsNotFullyQualified(LogRecordListener listener) {
ConfigurationParameters configurationParameters = mock(ConfigurationParameters.class);
when(configurationParameters.get(KEY)).thenReturn(Optional.of(CustomDisplayNameGenerator.class.getSimpleName()));
InstantiatingConfigurationParameterConverter<DisplayNameGenerator> converter = new InstantiatingConfigurationParameterConverter<>(DisplayNameGenerator.class, "display name generator");
Optional<DisplayNameGenerator> displayNameGenerator = converter.get(configurationParameters, KEY);
assertThat(displayNameGenerator).isEmpty();
assertExpectedLogMessage(listener, Level.WARNING, "Failed to load default display name generator class 'CustomDisplayNameGenerator' " + "set via the 'junit.jupiter.displayname.generator.default' configuration parameter. " + "Falling back to default behavior.");
}
Aggregations