offer TestKitBase trait, see #2174
This commit is contained in:
parent
ebc919ba61
commit
de59444795
3 changed files with 38 additions and 2 deletions
|
|
@ -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
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue