offer TestKitBase trait, see #2174

This commit is contained in:
Roland 2012-06-04 10:03:41 +02:00
parent ebc919ba61
commit de59444795
3 changed files with 38 additions and 2 deletions

View file

@ -14,6 +14,8 @@ import akka.dispatch.Futures
import akka.testkit.AkkaSpec
import akka.testkit.DefaultTimeout
import akka.testkit.ImplicitSender
import akka.util.NonFatal
object TestkitDocSpec {
case object Say42
case object Unknown
@ -251,5 +253,23 @@ class TestkitDocSpec extends AkkaSpec with DefaultTimeout with ImplicitSender {
}
//#event-filter
}
"demonstrate TestKitBase" in {
//#test-kit-base
import akka.testkit.TestKitBase
class MyTest extends TestKitBase {
implicit lazy val system = ActorSystem()
//#put-your-test-code-here
val probe = TestProbe()
probe.send(testActor, "hello")
try expectMsg("hello") catch { case NonFatal(e) => system.shutdown(); throw e }
//#put-your-test-code-here
system.shutdown()
}
//#test-kit-base
}
}