私は、俳優のpreStart()
の間に起こる何かにアサーションをする必要があるテストを持っていますが、それが起こるまで待つ方法を理解していないし、アサーションが作成される前にします)。私はこの試みている:テスト中にアクカの俳優を待つ方法は?
EventFilter.debug(start = "started", occurrences = 1).assertDone(10.seconds)
を、それを使用したとき、私は、エラーメッセージが表示されます。
import akka.actor._
import akka.testkit.EventFilter
import com.typesafe.config.ConfigFactory
class MyActor extends Actor with ActorLogging {
override def preStart(): Unit = {
log.debug("started MyActor...")
}
def receive = {
case m => log.debug(s"Received this message: $m")
}
}
object MyActor {
def props() = Props[MyActor]
}
object EventFilterTest extends App {
implicit val system = ActorSystem("testsystem", ConfigFactory.parseString("""
akka.loggers = ["akka.testkit.TestEventListener"]
akka.loglevel = "DEBUG"
"""))
EventFilter.debug(start = "started", occurrences = 1) intercept {
val myActor = system.actorOf(MyActor.props)
myActor ! "cows"
}
}
実行:
java.lang.AssertionError: assertion failed: 1 messages outstanding on DebugFilter(None,Left(started),false)
「やっと」試しましたか? (http://doc.scalatest.org/1.8/org/scalatest/concurrent/Eventually.html) – amorfis
@amorfis私はScalatestを使用していません。 –