鉴于我有一个Supervisor
注入了一个child
演员的演员,我如何向孩子发送 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