Loading tutorials
spring-boot-starter-test on the test classpath. The aim is to test a service class in isolation, without starting Spring, so the test runs i5 min readspring-boot-starter-test on the test classpath. The examples use Spring Boot 3.5 min read@SpringBootTest loads a context, how Spring profiles and application.properties work in a running application, and how @Bean methods and @Primary behave. It shows how to change configuration and beans for a test without touching production code.4 min read@SpringBootTest and @WebMvcTest. The chapter covers how to swap a real bean for a Mockito mock inside a running test context, and the errors this causes.5 min read@SpringBootTest and know what a Spring bean is. It also assumes you have used JUnit 5 and Mockito. You should know that @SpringBootTest loads the whole application context, which is the object that holds every bean in the application.5 min readspring-boot-starter-test. It covers what @DataJpaTest loads, how its transactions behave, how to run it against a real database, and the errors people hi5 min read@DataJpaTest and that Docker (or a compatible container runtime) is installed on your machine. Testcontainers is a Java library that sta6 min read@SpringBootTest and test slices. Here you will start the whole application on a real HTTP port and call it like a client would.5 min read@WebMvcTest controller test with MockMvc and replace collaborators with @MockitoBean. You should also know the basics of Spring Security: a filter chain, authentication, roles, and CSRF protection. Without extra setup, a secured endpoint turns your controll5 min read@JsonTest checks how your classes become JSON and back. @RestClientTest checks code that calls other services over HTTP. Both load a small part of the application, so they start quickly. The examples assume Spring Boot 3.x with spring-boot-starter-test5 min read@SpringBootTest and slice tests, that you know what a Spring bean is, and that you have run a Gradle or Maven test build. It explains why a suite of Spring tests can be fast or slow with the same number of tests, and how to keep it fast.7 min read@SpringBootTest, test slices, @MockitoBean, Testcontainers, and context caching. You should be able to write each kind of test already. The question here is how to keep a few hundred of them quick to run and trustworthy. A slow suite get6 min read