akka actor testing using play

2019-02-18 01:59发布

I want to test my akka actor. Is it possible to test every case of receive function?

def receive = {

  case msg: String =>
    println("SUCCESS" + msg)

  case user: VerifyIfUserExistActor =>
    implicit val timeout = Timeout(30 seconds)
    val future = platActor ? user
    val result = Await.result(future, timeout.duration).asInstanceOf[Users]
    sender ! result

  case ottDetails: OttDetails =>
    println("SUCCESS" + ottDetails)

}

1条回答
smile是对你的礼貌
2楼-- · 2019-02-18 02:16

Yes, if you want to test if you are sending a successful message and just want to see that your actor system works. You can use

case _ => println("sending message success")
查看更多
登录 后发表回答