Search in sources :

Example 1 with CustomDisplayNameGenerator

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();
}
Also used : CustomDisplayNameGenerator(org.junit.jupiter.engine.descriptor.CustomDisplayNameGenerator) Test(org.junit.jupiter.api.Test)

Example 2 with CustomDisplayNameGenerator

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.");
}
Also used : DisplayNameGenerator(org.junit.jupiter.api.DisplayNameGenerator) CustomDisplayNameGenerator(org.junit.jupiter.engine.descriptor.CustomDisplayNameGenerator) ConfigurationParameters(org.junit.platform.engine.ConfigurationParameters) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)2 CustomDisplayNameGenerator (org.junit.jupiter.engine.descriptor.CustomDisplayNameGenerator)2 DisplayNameGenerator (org.junit.jupiter.api.DisplayNameGenerator)1 ConfigurationParameters (org.junit.platform.engine.ConfigurationParameters)1