Programming

Writing Unit Test With MockMvcTester: Returning an Object as JSON

This blog post describes how we can write unit tests for a Spring MVC REST API endpoint that returns an object 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

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

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