Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mpkorstanje committed Nov 15, 2024
1 parent c6c21d9 commit 1a3293f
Showing 1 changed file with 13 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;

import java.util.Optional;
Expand Down Expand Up @@ -322,20 +324,9 @@ void shouldThrowWhenGlueScopedSpringBeanAreUsedOutsideLifecycle() {
}

@Test
void shouldBeStoppableWhenFacedWithInvalidConfiguration() {
void shouldBeStoppableWhenFacedWithBrokenContextConfiguration() {
final ObjectFactory factory = new SpringFactory();
factory.addClass(WithEmptySpringAnnotations.class);

IllegalStateException exception = assertThrows(IllegalStateException.class, factory::start);
assertThat(exception.getMessage(),
containsString("DelegatingSmartContextLoader was unable to detect defaults"));
assertDoesNotThrow(factory::stop);
}

@Test
void shouldBeStoppableWhenFacedWithMissingContextConfiguration() {
final ObjectFactory factory = new SpringFactory();
factory.addClass(WithoutContextConfiguration.class);
factory.addClass(WithBrokenContextConfiguration.class);

IllegalStateException exception = assertThrows(IllegalStateException.class, factory::start);
assertThat(exception.getMessage(), containsString("Failed to load ApplicationContext"));
Expand Down Expand Up @@ -392,13 +383,17 @@ public String getProperty() {
}

@CucumberContextConfiguration
@ContextConfiguration
public static class WithEmptySpringAnnotations {
public static class WithBrokenContextConfiguration {

}
@Configuration
public static class BrokenConfiguration {

@CucumberContextConfiguration
public static class WithoutContextConfiguration {
@Bean
public Object brokenBean(){
throw new RuntimeException("Oops!");
}

}

}

Expand Down

0 comments on commit 1a3293f

Please sign in to comment.