Scala Actor Examples with Unit Tests

The AkkaActorExample on github contains examples of how to create and unit test Akka actors. It consists of two simple actors:

  1. Calculator which does stateless arithmetic.
  2. An Accumulator which statefully accumulates values passed to it.

The CalculatorSpec unit tests show how to test actors. The Calculator companion object also contains a main function that is an example of how to use for-comprehension on futures. The AccumulatorSpec unit tests show how to write unit tests which access an actor’s internals.

All I did was distill the testing chapter in Derek Wyatt’s book Akka Concurrency down into a couple files that contain the bare minimum of code needed to serve as a template. There’s nothing deep here, but it still makes for a convenient starting point. Clone away.

Advertisements
This entry was posted in Those that have just broken the flower vase. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s