I am writing a new app and trying to do BDD using cucumber and Spring Boot 1.4. Working code is as shown below:
@SpringBootApplication
public class Application {
Prior to Spring Boot 1.4 you can use
@ContextConfiguration(classes = {YourSpringConfiguration.class}, loader = SpringApplicationContextLoader.class)
From Spring Boot 1.4 onwards SpringApplicationContextLoader is deprecated so you should use SpringBootContextLoader.class instead
Really just adding @SpringBootTest (with an optional configuration class) should work on its own, but if you look at the code in cucumber.runtime.java.spring.SpringFactory method annotatedWithSupportedSpringRootTestAnnotations it's not checking for that annotation, which is why simply adding that annotation in conjunction with @SpringBootTest works.
Really the code in cucumber-spring needs to change. I'll see if I can raise an issue as in the Spring docs it states that SpringApplicationContextLoader should only be used if absolutely necessary.I'll try and raise an issue for this for the cucumber spring support.
So as it stands stripwire's answer using a combination of @SpringBootTest and @ContextConfiguration is the best workaround.