在代码中设置akka TestKit默认超时

tar*_*sbl 7 scala akka

TestProbe.expectNoMsg()在不在config中的代码中设置默认超时的正确方法是什么?

我知道我可以akka.test.single-expect-default在application.conf中定义,但这适用于我的模块中的所有测试.或类似的东西

ActorSystem(.., ConfigFactory.parseString("{akka.test.single-expect-default = 0}"))
Run Code Online (Sandbox Code Playgroud)

在代码工作,但我希望能够设置此超时

implicit val timeout = Timeout(100 millis)
Run Code Online (Sandbox Code Playgroud)

我已经看过但是没有得到认可.

我的考试是

@RunWith(classOf[JUnitRunner])
class MySuite extends path.FunSpec with Matchers {

    implicit val system = ActorSystem("MySuite")

    val probe = new TestProbe(system)

    describe ("timeout") {
        println("Waiting..")
        probe.expectNoMsg()
        println("Waited")
    }
}
Run Code Online (Sandbox Code Playgroud)

fom*_*mil 3

你想设置

akka.test.single-expect-default
Run Code Online (Sandbox Code Playgroud)

在你的配置中

  • 谢谢,但我在帖子中提到了为什么这不理想。 (2认同)