测试Akka演员

时间:2015-06-11 14:22:49

标签: testing akka

我有以下演员定义:

class MyActor extends Actor {
    override def preStart(): Unit = {
        super.preStart()
        self ! M1("from M1")
    }

    def receive = initial("initial state")

    def initial(str: String): Receive = {
        case m1: M1 =>
            self ! M3("from M3")
            context.become(active(str))
        case m2: M2 => println(m2.str)

    }

    def active(str: String): Receive = {
        case m1: M1 => println(m1.str)
        case m3: M3 => println(m3.str)
        case str: String => println(s"string in active is ${str}")
    }
}

我的印象是我可以使用sbt来测试我的演员而且我继续在我的sbt控制台中执行以下操作:

val f = Await.result(myActor ? M1("hello world"), 10 seconds)

我留下了Timeout Exception。我怎么测试这个演员呢?我的意思是,我只想看看打印到控制台的内容!

0 个答案:

没有答案