I have complex component implementation which internally needs to create actor/s
for example:
class SubComponent(actorContext: ActorContext[_]) {
private val a = actorContext.spawn( ... )
}
class MainComponent(actorContext: ActorContext[_]) {
val subComponent: SubComponent = new SubComponent(actorContext)
}
with akka typed, actors are created with spawn function from ActorContext
I like to test that component with ActorTestKit
is it possible to get ActorContext from ActorTestKit?
ActorTestKit providing also spawn function, but ActorContext and ActorTestKit do not sharing some interface for this functionality.
So it is look like, that without custom interface I can not use provided akka components to solve this problem.
I am not “saving” it, just propagating it like implicit to be able to create underlying actors
class SubComponent()(implicit actorContext: ActorContext[_]) {
private val a = actorContext.spawn( ... )
}
class MainComponent()(implicit actorContext: ActorContext[_]) {
val subComponent: SubComponent = new SubComponent(actorContext)
}
with akka classic, actor was created by actor system, so more like everywhere, was propagated actor system, but akka typed changed that …