4 Comments

  1. 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).

  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.

Comments

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