Akka 如何等到孩子们活跃起来?

Akka 如何等到孩子们活跃起来?,akka,akka-typed,Akka,Akka Typed,我想测试我的主管演员,那会产生两个孩子。问题是,测试不会等待,直到主管演员的孩子开始 我正在使用ActorTestKit,按如下方式启动监控程序: private val onlineStoreTest = ActorTestKit("StoreTestOnline", withStoreOnlineConfig()) implicit val system = onlineStoreTest.system.toUntyped implicit val materializer =

我想测试我的主管演员,那会产生两个孩子。问题是,测试不会等待,直到主管演员的孩子开始

我正在使用
ActorTestKit
,按如下方式启动监控程序:

  private val onlineStoreTest = ActorTestKit("StoreTestOnline", withStoreOnlineConfig())

  implicit val system = onlineStoreTest.system.toUntyped
  implicit val materializer = ActorMaterializer()(onlineStoreTest.system)


  private val communicator = onlineStoreTest.createTestProbe[RpcCmd]("Communicator")
  private val trash = onlineStoreTest.createTestProbe[TrashTalk]("TrashTalk")
  private val onlineStore = onlineStoreTest.spawn(PersistenceSupervisor(Some(communicator.ref), trash.ref).create, "OnlineStoreActor")
以及测试:

Given("a messages receives from KAFKA")
      val msg = Message("TEST-KAFKA", "TESTED", """{data: payload}""", KAFKA)
      When("write into the store")
      onlineStore ! SavePersistenceMessage(SaveMessage(msg))
      onlineStore ! SavePersistenceMessage(SaveMessage(msg))
      onlineStore ! SavePersistenceMessage(SaveMessage(msg))
      And("read the written messages from store")
      Then("it should redirect the messages to the communicator")
      communicator.receiveMessage(10.seconds) should be(SendMessage(msg))
这里的问题是,
PersistenceSupervisor
中的子角色在测试开始时还没有准备好。所以考试就这样通过了


问题是,在测试开始之前,如何等待主管和孩子们完全准备好

我无法在你的帖子中添加评论或标记你的问题,所以我必须用其他方式

问题是,在测试开始之前,如何等待主管和孩子们完全准备好

最简单的方法是等待一段时间(即20秒),然后开始发送消息。或者尝试从此处使用解决方案