Programming

Writing Unit Tests With MockMvcTester: Returning a List as JSON

This blog post describes how we can write unit tests for a Spring MVC REST API endpoint that returns a list as JSON. We will identify the tests we must write, learn to eliminate duplicate request building code from our test class, and write assertions for the HTTP response with MockMvcTester and AssertJ. Read More

Introduction to MockMvcTester

This blog post describes what MockMvcTester is and explains why we should use it. We will also learn to configure MockMvcTester, send HTTP requests to the system under test, and write assertions for the returned HTTP response. Read More

Do We Need Unit Tests Anymore?

This blog post describes how automated testing tools have evolved during my software development career, identifies the reasons why integration, API, and end-to-end tests have become more popular, and explains how we can identify the tests which are most useful to us. Read More

How to Write Unit Tests Which Won't Tie Our Hands

This blog post describes why traditional unit tests can be painful to maintain, introduces a new technique that helps us to write unit tests which embrace change, and explains when we should use this new technique. Read More

3 Reasons Why We Shouldn’t Initialize Our Test Data With Production Code

It might seem convenient to initialize our test data with production code because this approach looks like a quick and easy way for setting up different test scenarios. In fact, it's a risk that can undermine the very purpose of our testing efforts. This blog post identifies the problems we face if we initialize our test data with production code and describes how we can write robust and useful tests. Read More

Writing Integration Tests for Spring Boot Web Applications: Spring Profiles

When we are writing integration tests for Spring Boot (web) applications, we typically don't want to use the configuration that's used when we run our application in the development, test, or production environment. This blog post describes how we can leverage Spring profiles when we have to create a separate configuration for our integration tests. Read More

Get practical tips and tutorials on test automation, Spring, and software development in your inbox. You’ll also never miss a new blog post. You can unsubscribe at any time.

My privacy policy identifies the information which I collect if you subscribe my email newsletter and describes how I use the collected information.