Spring Boot 2.x TestRestTemplate

Image for post
Image for post

Spring has lots of interesting features to make testing easier. There are many ways we can test our application. Often tests are about confidence but not only that tests are also about having a healthy and clean mindset for maintaining systems. For one reason or another there are migrations that need to happen, either for InfoSec remands or Business wants to have a better set of a new feature for user experience or simply the team wants to make the service right and faster. No matter the reason if you have a healthy set of tests your life will be much easier. The building is easier, maintaining system health requires discipline and tests are a very important part of it. Today I want to show how easy is for us to write proper and yet lightweight integration tests using Spring Boot 2.x and TestRestTemplate. There is a simple application I wrote and also a video which I will cover the code with more depth. So Let’s get started.

The Video

The Code

Cheers,

Diego Pacheco

Originally published at http://diego-pacheco.blogspot.com on January 10, 2021.

Written by

Brazilian, Software Architect, SWE(Java, Scala, Rust, Go) SOA & DevOps expert, Author. Working with EKS/K8S. diegopacheco.github.io (Opinions on my own)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store