Programming

Getting Started With MockK: The Setup

This blog post describes how we can configure the system under test and replace its dependencies with mocks when we are writing unit tests for a Kotlin application by using JUnit Jupiter and MockK. We will learn to get the required dependencies and configure the system under test by using both manual and extension-based configuration. Read More

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