scala import akka.actor.ActorRef import akka.actor.ActorSystem import akka.actor.Props import akka.testkit.TestKit import org.scalatest.WordSpecLike import org.scalatest.Matchers import akka.testkit.ImplicitSender class MyActorSpec extends TestKit(ActorSystem("testSystem")) with ImplicitSender with WordSpecLike with Matchers { class MyActor extends akka.actor.Actor { def receive = { case "hello" => sender() ! "world" } } "A MyActor" should { "return 'world' when receiving 'hello'" in { val myActor: ActorRef = system.actorOf(Props[MyActor]) myActor ! "hello" expectMsg("world") } } }


上一篇:
下一篇:
切换中文