Does anyone know where I can find a sample application where Cucumber is used to test a Spring Boot application through Gradle? I can run the tests fine starting the server on the cmd line and using my IDE, but I need to be able to run them all programmatically on the CI server. I saw the answer on here but that solution did not work for me, most likely because I have multiple step def files.
Here is my setup
build.grade (Mentioned in the other question)
testCompile ("org.springframework.boot:spring-boot-starter-test", ... "info.cukes:cucumber-spring:${cucumberVersion}")
CucumberTest.java
@RunWith(Cucumber.class) @CucumberOptions(format = "pretty", features = "src/test/resources") public class CucumberTest{ }
AbstractSpringTest.java (Extended by all the StepDef files)
@SpringApplicationConfiguration(classes = Application.class) @RunWith(SpringJUnit4ClassRunner.class) @Ignore public abstract class AbstractSpringTest { ... }
It's not doing the correct thing on start up because its 1. trying to initialize my step def files and 2. My application is not started and the cucumber tests cannot make a connection.
Thanks.
EDIT: Or if someone can tell me how to start and stop the application using gradle, that would be acceptable as well.
I have solved the issue with some help from this question.
Here is the repository with the answer: https://github.com/jakehschwartz/spring-boot-cucumber-example
In short, the AbstractSpringTest
class needs to have the following annotations:
@RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = DemoApplication.class, loader = SpringApplicationContextLoader.class) @WebAppConfiguration @IntegrationTest
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With