6 Comments

  1. I unfortunately have been unable to get cucumber to play ball with Spring Boot 2, I have tried using the same cucumber setup you have but I run into an initializationError when I run gradlew test. If I include the @Ignore on my steps class the test just skips completely and there is no output from cucumber. Any thoughts?

    1. Author

      I’m certainly not a gradle expert and I didn’t try to use it in this setup, but have you tried the setup described in this link? You can also point me to the code if it’s public and I can have a look.

  2. its my own code with the same approach that you talked about. I am running the test class with @RunWith(Cucumber.class)

    below is how my step’s parent class looks like.

    @RunWith(SpringRunner.class)
    @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)

    public class AbstractDefs {

    I had used the same dependencies that you had mentioned.

    1. Author

      I think I know what might be happening, I just reproduced that exception by removing the annotation @SpringBootApplication from the code’s main class (in my case SpringBootCucumberApplication). Check that your code (your main code, not the tests) has a proper configuration (e.g. are you missing the annotation?). Does the application start? If it does, then it might be that some configuration is overridden while running the tests.

  3. very good article. I was also looking for the same solutions. I tried with the approach, but I am getting an error with the below exception.

    java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=…) with your test

    1. Author

      Are you trying the same code or your own? Check which test class you’re running (the one with @RunWith(Cucumber.class)) and the class annotations (the steps’ parent class is annotated with @SpringBootTest).

Comments

This site uses Akismet to reduce spam. Learn how your comment data is processed.