There are a number of options for testing persistent actors when using the Akka Persistence Cassandra plugin. The two main methods are:

  • Testing using the inmem journal as shown in the Akka docs.
  • Testing against a real Cassandra instance.

For testing against Cassandra you can:

  • Use an existing cluster in your environment.
  • Install a local Cassandra cluster installed with your preferred method
  • Set up one locally with Cassandra Cluster Manager

Then there are options with tighter unit test framework integration:

For testing it can be convenient to enable automatic creation of keyspace and tables with configuration:

akka.persistence.cassandra {
  journal.keyspace-autocreate = on
  journal.tables-autocreate = on
  snapshot.keyspace-autocreate = on
  snapshot.tables-autocreate = on

Another recommended configuration is to not run test in parallel to avoid contention around manipulating the cassandra keyspace. Using sbt, you are able to control the parallelExecution as described here.

Found an error in this documentation? The source code for this page can be found here. Please feel free to edit and contribute a pull request.