When running Spring Boot tests using annotations like @SpringBootTest
or @DataJpaTest
, Spring Boot needs to find the main configuration class (annotated with @SpringBootApplication
or @Configuration
) to set up the application context properly. If Spring Boot cannot find the configuration class, it throws the error “Unable to find a @SpringBootConfiguration,” and the tests fail to execute.
Testing
How to Run JUnit 5 Tests with Spring Boot
If you’re building a Spring Boot application, you’ll likely want to test your code to ensure it’s working as expected. … Read more
Testing Spring Boot with TestRestTemplate
TestRestTemplate can be used to send http request in our Spring Boot integration tests. Such tests are usually executed with Spring boot run as a local server in a random port @LocalServerPort. So just need to create the request in integration tests and send it like a clients of your servers. TestRestTemplate have all necessary methods to send the request to server with a convenient way similar to RestTemplate.
Testing Spring Boot with REST Assured
Spring Boot and REST Assured is a great combination to build and test REST Web services. In this tutorial we will learn how to create a simple REST application and test it with REST Assured Framework.
Testing Spring Boot applications with MockMvc
In this tutorial we will learn how we can add unit testing to our basic Spring Boot application that we have discussed in this tutorial Using SpringBoot with JPA tutorial