Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Test-Driven Development with Java

You're reading from   Test-Driven Development with Java Create higher-quality software by writing tests first with SOLID and hexagonal architecture

Arrow left icon
Product type Paperback
Published in Jan 2023
Publisher Packt
ISBN-13 9781803236230
Length 348 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Alan Mellor Alan Mellor
Author Profile Icon Alan Mellor
Alan Mellor
Arrow right icon
View More author details
Toc

Table of Contents (21) Chapters Close

Preface 1. Part 1: How We Got to TDD
2. Chapter 1: Building the Case for TDD FREE CHAPTER 3. Chapter 2: Using TDD to Create Good Code 4. Chapter 3: Dispelling Common Myths about TDD 5. Part 2: TDD Techniques
6. Chapter 4: Building an Application Using TDD 7. Chapter 5: Writing Our First Test 8. Chapter 6: Following the Rhythms of TDD 9. Chapter 7: Driving Design – TDD and SOLID 10. Chapter 8: Test Doubles – Stubs and Mocks 11. Chapter 9: Hexagonal Architecture –Decoupling External Systems 12. Chapter 10: FIRST Tests and the Test Pyramid 13. Chapter 11: Exploring TDD with Quality Assurance 14. Chapter 12: Test First, Test Later, Test Never 15. Part 3: Real-World TDD
16. Chapter 13: Driving the Domain Layer 17. Chapter 14: Driving the Database Layer 18. Chapter 15: Driving the Web Layer 19. Index 20. Other Books You May Enjoy

What this book covers

Chapter 1, Building the Case for TDD, provides an understanding of the benefits TDD brings and how we got here.

Chapter 2, Using TDD to Create Good Code, covers some general good practices that will help us create well-engineered code as we apply TDD.

Chapter 3, Dispelling Common Myths about TDD, is a review of the common objections to using TDD that we might encounter, with suggestions for overcoming them. This chapter is suitable for business leaders who may have reservations about introducing a new technique into the development process.

Chapter 4, Building an Application Using TDD, involves setting up our development environment to build the Wordz application using TDD. It reviews how to work in short iterations using user stories.

Chapter 5, Writing Our First Test, introduces the basics of TDD with the Arrange, Act and Assert template. Writing the first test and production code for Wordz, we will look in detail at how TDD promotes a design step before we write code. We will consider various options and trade-offs, and then capture these decisions in a test.

Chapter 6, Following the Rhythms of TDD, demonstrates the red, green, refactor cycle as a rhythm of development. We decide on the next test to write, watch it fail, make it pass, and then refine our code to be safe and simple for the team to work with in the future.

Chapter 7, Driving Design – TDD and SOLID, builds on previous chapters showing how TDD provides rapid feedback on our design decisions by bringing SOLID into the fold. The SOLID principles are a useful set of guidelines to help design object-oriented code. This chapter is a review of those principles so that they are ready for us to apply in the rest of the book.

Chapter 8, Test Doubles – Stubs and Mocks, explains two critical techniques that allow us to swap out things that are difficult to test for things that are easier to test. By doing so, we can bring more of our code under a TDD unit test, reducing our need for slower integration testing.

Chapter 9, Hexagonal Architecture – Decoupling External Systems, presents a powerful design technique that enables us to fully decouple external systems such as databases and web servers from our core logic. We will introduce the concepts of ports and adapters here. This simplifies the use of TDD and as a benefit, provides resilience to any changes imposed on us by external factors.

Chapter 10, FIRST Tests and the Test Pyramid, outlines the test pyramid as a means of thinking about the different kinds of tests needed to fully test a software system. We discuss unit, integration, and end-to-end tests and the trade-offs between each type.

Chapter 11, How TDD Fits into Quality Assurance, explores how when using advanced test automation as described in this book, our QA engineers are freed up from some of the laborious detailed testing that they might have otherwise had to do. This chapter looks at how testing is now a whole-team effort throughout development, and how we can best combine our skills.

Chapter 12, Test First, Test Later, Test Never, reviews some different approaches to testing based on when we write the tests and what exactly we are testing. This will help us increase the quality of the tests we produce when applying TDD.

Chapter 13, Driving the Domain Layer, walks through applying TDD, SOLID, the test pyramid, and hexagonal architecture to the domain layer code of Wordz. Combined, these techniques enable us to bring most of the game logic under fast unit tests.

Chapter 14, Driving the Database Layer, offers guidance on writing the adapter code that connects to our SQL database, Postgres, now that we have decoupled the database code from the domain layer. We do this test-first, writing an integration test using the Database Rider test framework. The data access code is implemented using the JDBI library.

Chapter 15, Driving the Web Layer, rounds off as the final chapter of the book by explaining how to write an HTTP REST API that allows our Wordz game to be accessed as a web service. This is done test-first, using an integration test written using the tools built into the Molecule HTTP server library. Having completed this step, we will finally wire up the entire microservice ready to be run as a whole.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime