Skip to content

Testing

Assert on What Happened, Not on Who Was Called: Black-Box Testing in Event-Sourced Systems

Every codebase has a function like this one: It started as three lines of conditional logic, then a regulation changed, then a second product type arrived, and now it crosses half a screen. It looks important. Skipping tests on it would feel irresponsible, so it gets a test class of its own, almost without thinking.

That reflex is usually explained by complexity. That explanation is wrong. What decides whether you end up writing white-box tests is not how complicated your code is. It is whether the business outcome exists anywhere as a value you can point at. We'll follow one rule from the inside of a helper to the outside of a system, and event sourcing turns out to matter for a reason that has nothing to do with fashion.