O'Reilly logo

Building Applications with Scala by Diego Pacheco

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding Akka tests

We will create three more tests: one for each actor that we have. They are located at ReactiveWebStore/test/.

Scala test for Akka Actor

ChatUserActorSpec.scala should look something like this:

 class OutActor extends Actor { def receive = { case a:Any => Unit } } class ChatUserActorSpec extends PlaySpec { class Actors extends TestKit(ActorSystem("test")) "ChatUserActor" should { "joins the chat room and send a message" in new Actors { val probe1 = new TestProbe(system) val actorOutRef = TestActorRef[OutActor](Props[OutActor]) val actorRef = TestActorRef[ChatUserActor] (ChatUserActor.props(system)(actorOutRef)) val userActor = actorRef.underlyingActor assert(userActor.context != null) val msg = "testUser:test msg" probe1.send(actorRef,msg) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required