0

The Complete Guide to REST (Controller) Tests in Spring Boot: Unit and Integration Tests

Spring Boot Test

There are different ways to test your Controller (Web or API Layer) classes in Spring Boot, some provide support to write pure Unit Tests and some others are more intended to be used for Integration Tests. Within this post, I’ll cover the main three test approaches available for Spring: using MockMVC in standalone mode, MockMVC together with SpringRunner, and using SpringBootTest.

Continue Reading

9

Test Coverage analysis (with JaCoCo and Sonar) for your Spring Boot app

One of the main metrics for a software project is Test Coverage: if done properly, it gives you a quick picture about how much code is ‘protected’ by tests.

In this article, I’ll show you how to use a minimal configuration for including JaCoCo in our Spring Boot application, and how to process this information with Sonar.

Continue Reading

0

Integration testing with Mockito and Spring Boot

Within this post, I show you how to setup properly a Unit Test in Spring Boot performing HTTP requests with Mockito. In this case, I’m testing directly against data to be placed into the model, but a similar test could be written for checking a REST API.

Sometimes testing web access with Spring Boot can be tricky. There are some specific annotations to be used, being the configuration to use maybe the most important one.

Continue Reading