私はScalaTest
フォローのために最初に書き込もうとしていますActor
object Runner {
def props(race: Race) = Props(classOf[Runner], race)
}
class Runner(race: Race) extends Actor with ActorLogging {
import context.dispatcher
@throws[Exception](classOf[Exception])
override def postRestart(reason: Throwable): Unit = context.parent ! RestartRunner
override def receive: Receive = LoggingReceive {
case Start => {
log.debug("running...")
for (i <- 1 to 3) {
Thread.sleep(200)
}
throw new RuntimeException("MarathonRunner is tired")
}
case StartWithFuture =>
log.debug("I am starting to run")
race.start pipeTo self
case Failure(throwable) => throw throwable
case Stop =>
log.debug("stopping runner")
context.stop(self)
}
}
私もです
import akka.actor.{Props, ActorSystem}
import akka.testkit.{TestActorRef, TestKit}
import org.scalatest._
class RunnerSpec extends TestKit(ActorSystem("test"))
with WordSpecLike
with MustMatchers {
"A Runner Actor" must {
val runner = TestActorRef(Props(new Runner(new Marathon)))
"receive messages" in {
runner ! Start
runner.under <== says Nothing (see attachment)
}
}
}
しかし、私が見ているのは
なぜ私は戻ってこないのRunner Actor
ですか?