Drive development with automated tests and feel confident about writing high-quality software
Key Features
- Get up and running with common design patterns and best practices involved in TDD
- Apply the rhythms of TDD - arrange, act, assert and red, green, refactor
- Understand the challenges of implementing TDD in the Java ecosystem and build a plan
Book Description
Test-Driven Development enables developers to craft well-designed code and prevent defects. It is a simple, yet powerful, tool to focus us on the design of our code, whilst automatically checking that our code works correctly. Mastering TDD will instill some efficient design patterns and help you become an excellent software architect.
The book will begin by getting the basics by explaining good code and bad code, bursting common myths, and explaining why Test-driven development is crucial. Then we will gradually move toward building a sample application using TDD, where we will apply the two key rhythms of red, green, refactor and arrange, act, assert. We will lean how to bring external systems like databases under control by using dependency inversion and test doubles. We will then delve into some advanced design techniques like SOLID patterns, Refactoring and Hexagonal Architecture. Using the Test Pyramid as a guide, we will balance our use of fast, repeatable unit tests against integration tests. Towards the end of the book, you will work towards implementing TDD in real-world use cases and scenarios, developing a modern REST microservice backed by a Postgres database in Java 17.
By the end of this book, you will be thinking differently about how you design code for simplicity and how correctness can be baked in as you go.
What you will learn
- Write effective test cases in Java
- Explore how TDD can be incorporated into crafting software
- Learn to write reusable and robust code in Java
- Uncover common myths about TDD and understand its effectiveness
- Understand the accurate rhythm of implementing TDD
- Understand the process of refactoring and how it affects the TDD process
Who This Book Is For
The book is targeted at expert java developers and software architects crafting high-quality software in Java. This book can be picked up by anyone with strong working experience in Java and planning to use Test-driven development for their upcoming projects.
Table of Contents
- Why good code goes bad
- TDD: Clean code, correct code
- Common myths about TDD
- Building a typical application using TDD
- Writing our First Test
- The rhythm of TDD: Red, Green, Refactor
- Driving Design: TDD and SOLID
- Test Doubles: Stubs and Mocks
- Hexagonal Architecture: Decoupling external systems
- FIRST Tests and the Test Pyramid
- TDD and the role of manual testing
- Test First, Test Later, Test Never
- Driving the domain layer
- Driving the database layer
- Driving the Web adapter