Efficient Testing with FIRST Unit Tests in Hexagonal Architecture
Explore how hexagonal architecture enables writing fast, reliable FIRST unit tests around user stories by isolating domain logic with test doubles. Understand testing behavior over implementation details to improve maintainability and reduce reliance on slower integration tests.
The previous lesson introduced the idea of surrounding our domain model with test doubles for every port. This gives us some interesting opportunities to discuss in this section. We can test units that are as large as a user story.
Behavioral layering in Hexagonal architecture
We’re familiar with unit tests as being things that test in the small. There’s a good chance you’ll have heard somebody say that a unit test should only ever apply to a single function, or that every class should have one unit test for every method. We’ve already seen how that’s not the best way to use unit tests. Tests like those miss out on some advantages. We’re better served by thinking of tests as covering behavior instead. ...