Hasty Briefsbeta

Bilingual

OpenCQRS 2.0: Tests That Read Like the Domain

3 hours ago
  • #testing
  • #event-sourcing
  • #cqrs
  • OpenCQRS 2.0 introduces a fluent Given/When/Then DSL that makes event-sourced tests read like domain specifications, acting as documentation that can't rot.
  • Event sourcing changes testing by reducing ceremony, eliminating the need for mocks, and allowing tests to mirror command handlers as pure functions with events as inputs and outputs.
  • The framework enforces consistency through preconditions like SubjectIsPopulated and EventQlQueryIsTrue, ensuring tests align with database-enforced business rules.
  • The update includes modernizations like Spring Boot 4.1, Jackson 3, Gradle 9, EventSourcingDB 1.2 support, and JSpecify annotations for better null-safety.
  • OpenCQRS 2.0 also adds features like readSubjects for hierarchical stream discovery and improved handling of deterministic time in tests for temporal domain rules.