Hexagonal architecture and Python - Part IV: Lightweight integration tests
Posted on 10 May 2025 in Articles • Tagged with architecture, django, hexagonal architecture, lightweight integration tests, programming, python, testing • 14 min read

It's pretty straightforward to unit test the components of an application that follows Hexagonal Architecture. The components are part of specific layers, and mocking the next dependency layer is usually simple. However, this approach means we never test the application as a whole and have to rely on expensive integration or end-to-end tests to do so.
We can test the application components in sociable manner, leaving our components' direct dependencies as-is, and pushing the mocks further to the application edges.
If we push the mocks too far, we end up with lightweight integration tests. Let's explore how we can utilise such tests in a context of Django application and what benefits we can reap.
Continue reading