У меня @ConditionalOnProperty(value = jms.enabled)
на интерфейсе, который расширяет JpaRepository
, как я могу протестировать создание bean-компонента? Я пробую
private final ApplicationContextRunner runner =
new ApplicationContextRunner().withConfiguration(UserConfigurations.of(SomeRepository.class));
@Test
public void shouldCreateBeanWhenJmsEnabled() {
runner.withPropertyValues("jms.enabled=true")
.run(context -> assertThat(context).hasBean("someRepository"));
}
, но получаю
java.lang.AssertionError:
Expecting:
<Unstarted application context org.springframework.boot.test.context.assertj.AssertableApplicationContext[startupFailure=org.springframework.beans.factory.BeanCreationException]>
to have bean named:
<"someRepository">:
but context failed to start:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'someRepository': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.kek.repository.SomeRepository]: Specified class is an interface