I'm trying to unit test a helper function of my actor. This helper function spawns some actors and I want to assert that this happens. In order to spawn them, the helper function needs the parent ActorContext, so that is passed in. Example:
def getDefaultInitialState(context: ActorContext[Request]): State = {
...
val actor1 = context.spawn(myChildActor(), name = f"MyChild1")
...
State(actor1, ...)
}
So, now I'm trying to unit test this function. In order to call it from my unit test, I need an ActorContext[Request]. I tried doing this in my test:
val testKit = BehaviorTestKit(MyParentActor()))
getDefaultInitialState(testKit.context())
Unfortunately, this doesn't work because the context() method of BehaviorTestKit is private.
How can I make this work?