Book Image

Test-Driven Development with Java

By : Alan Mellor
5 (1)
Book Image

Test-Driven Development with Java

5 (1)
By: Alan Mellor

Overview of this book

Test-driven development enables developers to craft well-designed code and prevent defects. It’s a simple yet powerful tool that helps you focus on your code design, while automatically checking that your code works correctly. Mastering TDD will enable you to effectively utilize design patterns and become a proficient software architect. The book begins by explaining the basics of good code and bad code, bursting common myths, and why Test-driven development is crucial. You’ll then gradually move toward building a sample application using TDD, where you’ll apply the two key rhythms -- red, green, refactor and arrange, act, assert. Next, you’ll learn how to bring external systems such as databases under control by using dependency inversion and test doubles. As you advance, you’ll delve into advanced design techniques such as SOLID patterns, refactoring, and hexagonal architecture. You’ll also balance your use of fast, repeatable unit tests against integration tests using the test pyramid as a guide. The concluding chapters will show you how to implement TDD in real-world use cases and scenarios and develop a modern REST microservice backed by a Postgres database in Java 17. By the end of this book, you’ll be thinking differently about how you design code for simplicity and how correctness can be baked in as you go.
Table of Contents (21 chapters)
1
Part 1: How We Got to TDD
5
Part 2: TDD Techniques
15
Part 3: Real-World TDD

Part 1: How We Got to TDD

In Part 1, we look at how we got to TDD in the software industry. What problems are we trying to fix with TDD? What opportunities does it create?

In the following chapters, we will learn about the benefits that TDD brings to businesses and developers. We’ll review the basics of good code to provide something to aim for when we first start writing our tests. Knowing that teams are sometimes hesitant to start using TDD, we will examine six common objections and how to overcome them.

This part has the following chapters: