【发布时间】:2016-01-26 14:13:00
【问题描述】:
鉴于我有一个注入了child 演员的Supervisor 演员,我如何向孩子发送 PoisonPill 消息并使用 TestKit 进行测试?
这是我的主管。
class Supervisor(child: ActorRef) extends Actor {
...
child ! "hello"
child ! PoisonPill
}
这是我的测试代码
val probe = TestProbe()
val supervisor = system.actorOf(Props(classOf[Supervisor], probe.ref))
probe.expectMsg("hello")
probe.expectMsg(PoisonPill)
问题是没有收到PoisonPill 消息。
可能是因为探测被PoisonPill 消息终止?
断言失败
java.lang.AssertionError: assertion failed: timeout (3 seconds)
during expectMsg while waiting for PoisonPill
【问题讨论】:
标签: scala testing akka testkit