Actor-based systems are different from systems that are built using a traditional approach. Naturally, testing actors is different from regular testing. Actors send and receive messages in an asynchronous manner and are usually examined via message flow analysis. A typical setup will include three parts:
- The source of the messages
- The actor under test
- The receiver of the actor's responses
Luckily, Akka includes a testing module that abstracts a lot of setup logic and provides useful helpers for common testing activities. The name of the module is Akka TestKit and it is contained in a separate module that needs to be added to the project's test scope:
libraryDependencies += "com.typesafe.akka" %% "akka-testkit" % akkaVersion ...