我正在尝试编写我的第一个 Akka 测试并浏览文档。我正在运行它的第一个示例并收到以下错误:
[错误] [10/26/2017 14:08:55.371] [IngestionWorkerActorSpec-akka.actor.default-dispatcher-4] [akka://IngestionWorkerActorSpec/user/$b] 断言失败:expectMsg 期间超时(3 秒)在等待测试消息时 java.lang.AssertionError:断言失败:在 expectMsg 期间等待测试消息时超时(3 秒)
下面是我的测试演员的接收方法:
override def receive: Receive = {
case p: ProducerRecord[_,_] =>
sendChannel.send(p.value())
case _ => logger.error("Unknown type Producer Record Received.")
}
测试规格:
val uutActor =system.actorOf(IngestionWorkerActor.props(config, KafkaProducer))
"An actor must send " should {
"send back messages unchanged" in {
uutActor ! expected
Thread.sleep(50)
expectMsg(expected)
}
}
我想测试我的演员是否收到发送给它的消息,后来我想修改它以查看我是否收到特定消息。任何帮助表示赞赏。