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 quickly lost. Actors provide an interesting solution to this problem for the following reasons:

  • Actors fit 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 the messages.

In this chapter you will learn two different methods for testing actors. On the one hand, you will 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, that is the parent of all the others, and also manages the resources of the application. On the other hand, you will test Actors in a real-world context where multiple Actors interact with each other and messages arrive in indeterminate order. Accordingly, you will learn testing in synchronous and asynchronous settings.

4.1 Sync testing

 
 

4.1.1 Effects

 
 
 

4.1.2 More than one actor

 
 

4.1.3 Testing the logs

 

4.2 Async Testing

 
 
 
 

4.2.1 Using probes

 
 
 
 

4.2.2 Monitoring

 
 
 

4.2.3 Fishing messages

 

4.2.4 Logging

 
 
 

4.2.5 Log Capturing

 
 
 

4.3 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