Skip to content

gangstead/specs2-akka-testkit-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

specs2-akka-testkit-demo

Intro

This is a dead simple demo to test Actors with specs2 with Akka TestKit. The code is modified from the demo code at http://doc.akka.io/docs/akka/snapshot/scala/testing.html#Asynchronous_Integration_Testing_with_TestKit, which is for scalatest.

The end result is very simple but I had to take the code apart and put it back together again to understand it.

Running

> sbt test

Key take away

Everything is in the docs, but the part that I didn't notice the first few times I read them was that expectMsg and other assertions don't work for all actors, they only monitor testActor, a special ActorRef provided by TestKit. If you are testing a response from an actor you have to use the non-sugared tell syntax so that testActor gets the response acotor ! (msg, testActor) or mix in the trait with ImplicitSender so that testActor shows up as the sender to all messages send in the test.

About

Testing Actor systems in Scala with specs2 and Akka Testkit

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages