When testing is limited to a single component, anyone can test quickly. But when testing includes integrations, ease and speed are usually lost. Actors provide an interesting solution to this problem for the following reasons:
- Actors fit in with Behavior Driven Development (BDD) because they embody behavior as a fundamental primitive.
- Actors come in systems and are therefore fundamentally built on integration.
- Actors are based on messaging, which has huge advantages for testing because you can simulate any behaviors by sending messages.
In this chapter, you learn two methods for testing actors. On the one hand, you learn how to stub the ActorSystem to test actors in isolation and with deterministic guarantees. You may remember from the previous chapters that the ActorSystem is the first actor, the parent of all the others, and also manages the application’s resources. On the other hand, you test actors in a real-world context where multiple actors interact with each other and messages arrive in an indeterminate order. Accordingly, you learn about testing in synchronous and asynchronous settings.