akka 如何增加ScalaTestWithActorTestKit的默认超时

yb3bgrhw  于 2022-11-05  发布在  Scala
关注(0)|答案(1)|浏览(174)

我有一个从消息处理程序内部构造另一个事件来源参与者的测试,这个构造花费了3秒多。下面是当前的配置,我如何增加默认超时?

extends ScalaTestWithActorTestKit(
    ConfigFactory.parseString("""
    akka.persistence.testkit.events.serialize = off
    akka.actor.allow-java-serialization = on
    akka.test.single-expect-default = 999s
    """).withFallback(PersistenceTestKitPlugin.config).withFallback(ManualTime.config)

以下是错误消息:

Timeout (3 seconds) during receiveMessage while waiting for message.
java.lang.AssertionError: Timeout (3 seconds) during receiveMessage while waiting for message.
6gpjuf90

6gpjuf901#

请尝试使用构造函数:* 公共的可扩展测试工具包(com.typesafe.config.config)*
中的类似构造函数(它对我有效):

extends TestKit(ActorSystem("AliveActorSpec", ConfigFactory.load(ConfigFactory.parseString("""
                                                                                                                  | akka {
                                                                                                                  |   test {
                                                                                                                  |     single-expect-default = 6s
                                                                                                                  |   }
                                                                                                                  | }
  """.stripMargin))))

相关问题