Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gangstead/specs2-akka-testkit-demo
Testing Actor systems in Scala with specs2 and Akka Testkit
https://github.com/gangstead/specs2-akka-testkit-demo
Last synced: 24 days ago
JSON representation
Testing Actor systems in Scala with specs2 and Akka Testkit
- Host: GitHub
- URL: https://github.com/gangstead/specs2-akka-testkit-demo
- Owner: gangstead
- Created: 2015-03-02T23:01:45.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-03-02T23:10:43.000Z (almost 10 years ago)
- Last Synced: 2024-10-15T17:57:50.918Z (2 months ago)
- Language: Scala
- Size: 117 KB
- Stars: 4
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
specs2-akka-testkit-demo
========================# Intro
This is a dead simple demo to test Actors with [specs2](http://etorreborre.github.io/specs2/) with Akka [TestKit](http://doc.akka.io/docs/akka/snapshot/scala/testing.html). 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](http://www.scalatest.org/).The end result is very simple but I had to take the code apart and put it back together again to understand it.
# Running
```bash
> 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.