Test-Driven Development with Java by Alan Mellor

Test-Driven Development with Java by Alan Mellor

Author:Alan Mellor
Language: eng
Format: epub
Publisher: Packt
Published: 2023-11-15T00:00:00+00:00


We’ve already learned how to write tests using the arrange, act, and assert template. We’ve also learned about some software design principles, known as the SOLID principles, that help us break our software down into smaller components. Finally, we’ve learned how test doubles can stand in for collaborating components to make FIRST unit tests easier to write. In this chapter, we’re going to combine all those techniques into a powerful design approach known as the hexagonal architecture.

Using this approach, we will benefit from getting more of our application logic under unit tests and reducing the number of integration and end-to-end tests required. We will build in a natural resilience to changes outside our application. Development chores such as changing a database supplier will be simplified, by having fewer places where our code needs to be changed. We will also be able to unit test across larger units, bringing some tests that require end-to-end testing in other approaches under unit tests instead.

In this chapter, we’re going to cover the following main topics:

Why external systems are difficult

Dependency inversion to the rescue

Abstracting out the external system

Writing the domain code

Substituting test doubles for external systems

Unit testing bigger units

Wordz – abstracting the database



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.