February 2018
Intermediate to advanced
552 pages
13h 46m
English
Now let's unit test our HelloWorldActor version 2 which is available at com.packt.publishing.reactive.hello.actor.v2 package name:
class HelloWorldActorSpec(actorSystem: ActorSystem) extends TestKit(actorSystem) with Matchers with WordSpecLike with BeforeAndAfterAll {
def this() = this(ActorSystem("AkkaHelloWorld"))
"HelloWorld Actor" should {
"pass on a HelloWorld message" in {
val testProbe = TestProbe()
val helloWorldActor = system.actorOf(Props(new HelloWorldActor(testProbe.ref)), "HelloWorldActor")
helloWorldActor ! HelloWorld
testProbe.expectMsg(500 millis, HelloWorld)
}
}
override def afterAll: Unit = {
shutdown(system) }}
Let us understand the preceding Test spec here:
Read now
Unlock full access