Giriş
Açıklaması şöyle.
Şöyle yaparız.
Açıklaması şöyle.
The family of the context runners, ApplicationContextRunner, ReactiveWebApplicationContextRunner, and WebApplicationContextRunner, provide an easy and straightforward way to tailor the context on per test method level, keeping the test executions incredibly fast.run metodu
Şöyle yaparız.
public class LoggingConfigurationTest {
private final ApplicationContextRunner runner = new ApplicationContextRunner()
.withConfiguration(UserConfigurations.of(LoggingConfiguration.class));
@Test
public void loggerShouldBeSlf4j() {
runner
.run(ctx ->
assertThat(ctx.getBean(Logger.class)).isInstanceOf(Logger.class)
);
}
@Test
public void loggerShouldBeNoop() {
runner
.withPropertyValues("logging.enabled=false")
.run(ctx ->
assertThat(ctx.getBean(Logger.class)).isSameAs(NOPLogger.NOP_LOGGER)
);
}
}
Hiç yorum yok:
Yorum Gönder