Testing vertical slice architecture (VSA) requires a mindset shift away from mocking layers. The right unit to test is the slice itself: send a real HTTP request in, verify the database state out, using WebApplicationFactory and Testcontainers with a real Postgres instance. Fakes are reserved only for third-party services you don't own. Unit tests still apply for extracted domain logic with complex rules, while architecture tests enforce that slices don't reference each other. This approach catches routing, validation, mapping, and persistence bugs in one pass and survives internal refactoring because tests are coupled to behavior, not implementation.
Table of contents
The Slice Is the UnitThe Setup That Makes It PracticalWhere Unit Tests Still Earn Their KeepKeep the Slices From Growing Into Each OtherSummary9.9K Impressions