假设我有一个被注入了一个子actor的Supervisor
actor,我该如何向子actor发送一个PoisonPill消息,并使用TestKit进行测试?
这是我的Supervisor。
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