4 Akka test kit

 

This chapter covers

  • Testing actors with the Akka test kit
  • Testing synchronous scenarios
  • Testing asynchronous scenarios

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.

4.1 Testing approaches

 
 

4.2 Sync testing

 
 

4.2.1 Effects

 

4.2.2 More than one actor

 

4.2.3 Testing the logs

 
 
 

4.3 Async testing

 
 
 

4.3.1 Using probes

 
 
 

4.3.2 Fishing for messages

 

4.3.3 Logging

 
 
 

4.3.4 Log capturing

 
 
 

Summary

 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest