3 Test driven development with actors

 

This chapter covers

  • Unit testing actors synchronously
  • Unit testing actors asynchronously

Everyone has a rapid, fluid experience on the testing unit side when testing is confined to a single component. Tests that involve integrations are where ease and speed generally evaporate rapidly. Actors provide an interesting solution to this problem for the following reasons:

  • Actors are a more direct match for tests because they embody behavior (and almost all TDD has at least some BDD—behavior-driven development—in it).
  • Too often, regular unit tests test only the interface, or have to test the interface and functionality separately.
  • Actors are built on messaging, which has huge advantages for testing, because you can easily simulate behaviors by sending messages.

In this chapter, we’ll see two different ways of testing actors. First, we’ll look at stubbing Actor systems to test actors in isolation with deterministic guarantees. On the other side, we’ll be testing actors in a real context, where multiple actors interact with each other and abide messages that arrive in an indetermined order. Respectively, we will be testing Synchronously and Asynchronously. 

3.1 Sync testing

 

3.1.1 More than one actor

 

3.1.2 Testing the logs

 

3.2 Async Testing

 
 
 

3.2.1 The basics. Message received

 

3.2.2 A Manual forward clock

 
 
 
 

3.2.3 Testing logging

 

3.2.4 Configuration for testing

 
 

3.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