Skip to content

The same acceptance tests, on four different databases

Hexagonal architecture promises adapter interchangeability, but in practice, this promise often remains implicit, with nothing in the code to verify it.

In Phexium, Behat scenarios run against InMemory, SQLite, MySQL and PostgreSQL repositories. The same .feature file, the same step definitions, the same assertions. Only an environment variable changes.

The task runner launches the same Behat suite four times, each time with a different backend. Before each scenario, a hook creates a temporary database (or resets the InMemory collections). Afterward, it tears it down.

A scenario that passes on SQLite but fails on PostgreSQL reveals a gap between the adapter and the port contract. The defect is pinpointed unambiguously: it is the SQL implementation that diverges, not the business logic.

The overhead of four passes across four backends remains marginal. The databases run in-memory inside Docker containers. The entire test suite completes in about fifteen seconds. But in return, every adapter is verified by the same business scenarios. The port contract is no longer a documented convention, it is an observable fact in the CI.