Chapter 3. Test-driven development with actors

 

In this chapter

  • Unit testing actors synchronously
  • Unit testing actors asynchronously
  • Unit testing actor messaging patterns

It’s amusing to think back to when TDD first appeared on the scene—the primary objection was that tests took too long, and thus held up development. Though you rarely hear that today, there’s a vast difference in the testing load both between different stacks, and through different phases (such as unit versus integration tests). Everyone has a rapid, fluid experience on the unit side, when testing is confined to a single component. Tests that involve collaborators 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.

3.1. Testing actors

3.2. One-way messages

3.3. Two-way messages

3.4. Summary

sitemap