Clean Test Automation Monthly 6 / 2023

The Clean Test Automation Monthly is a monthly blog post that highlights the best test automation content which I read during the current month. This blog post is always published on the last day of the month.

Let's begin!

How to detect the Hibernate N+1 query problem during testing describes how you can write assertions for the number of invoked SQL statements (DELETE, INSERT, SELECT, and UPDATE) by using the Hypersistence Utils library when you are using JPA and Hibernate. Like the title of this blog post suggests, this approach is useful if you want to write tests which help you to avoid the N+1 query problem.

Mastering the Object Mother describes how you can solve the problems caused by static factory methods by writing an object mother class which uses builders for emphasizing the important parts of the test data.

Spring Boot Application Testing and Development with Testcontainers describes how the TestContainers support which was added in Spring Boot 3.1 makes our life easier when we want to start docker containers before our integration tests are run or run our application in our development environment.

Docker Compose Support in Spring Boot 3.1 identifies the problems caused by Docker Compose and describes how we can solve these problems by using the Docker Compose support of Spring Boot 3.1. To make matters more interesting, it seems that can generate a sensible Docker Compose file which means that using this new feature should be quite easy.

Spring TestContext Framework: Context Failure Threshold is a new (and extremely useful) feature of Spring Framework 6.1 which allows us to configure the number of attempts which are made to load a failing application context by using the same context cache key. If this threshold is exceeded, the subsequent attempts to load the same application context will fail immediately. In other words, this feature ensures that our tests will fail a lot faster if they cannot load the application context for some reason.

Working with jOOQ and Flyway using Testcontainers explains how we can implement our data access layer with jOOQ, run our database migration scripts with Flyway, and write integration tests for our repositories. I selected this blog post on this list because it's quite rare to find a blog post that explains what's the difference between the @SpringBootTest annotation and a persistence layer slice annotation (@JooqTest).

Worst MockMvc Test Antipattern: Don't use ObjectMapper! argues that we shouldn't use ObjectMapper for generating the request body that's send to the system under test. This blog post kind of started to haunt me and I decided to write an article series that explores how we can generate the request body without using ObjectMapper and helps us to select the best option for us. In other words, this blog post had a huge effect on me and I recommend that you read it.

How to Write MockMvc Tests Without ObjectMapper, Part One - The Simplest Possible Solution is my own blog post that describes how we can build the request body that's send to the system under test when we cannot use ObjectMapper, we must use the simplest possible solution, and we must use Java.

P.S. If you want to get my Introduction to JUnit 5 course, now is the time to do it. I will increase the price of the course on Monday after I have added the missing exercises to the Writing Assertions With JUnit 5 topic.

0 comments… add one

Leave a Reply