Property based integration testing for Axon applications
Tim van Heugten will show that property based testing is a good match for Axon applications, and how this is used for integration tests of backend services at bol.com.
Unit and integration tests have been largely implemented using scenarios. Small examples of specified input that, when applied to the system, should match up to a specific output. But there is alternative; With property based testing the system is fed a random input. Then, the output is validated against certain contracts, or properties, that should hold for all inputs.
This replaces the tedious task of working out and implementing the scenarios by the more challenging (and complex) task of specifying the properties. Or alternatively, for properties that cannot be described both sufficiently generic and sufficiently specific, the system output can be verified using the output of a reference implementation.
Axon lends itself well for this method of integration testing, since the input for the system is behavior, in the form of a stream of commands. Axon takes care of applying the commands, while the query side can be used to validate the state, or output, of the system. We use junit-quickcheck (http://pholser.github.io/junit-quickcheck) to generate a random stream of commands as input. These commands are then run through a small module that takes care of dispatching the command, updating a reference model, and verification of the properties.
The result is an integration test that covers the command side, the query side, and the persistence layer. These tests contain complex random scenarios, and are easily extendible with new commands and properties to check.