Could not find implicit value for parameter system: akka.actor.ActorSystem

I am creating a unit test case for an Akka actor using TestActorRef .

 def actorRefFactory = context implicit def executionContext = actorRefFactory.dispatcher implicit val OutputActor = actorRefFactory.actorOf(Props[OutputActor], "OutputActor") val actorRef = TestActorRef[OutputActor] val actor = actorRef.underlyingActor 

Getting the following error while creating actorRef:

 - could not find implicit value for parameter system: akka.actor.ActorSystem - not enough arguments for method apply: (implicit t: scala.reflect.ClassTag[org.musigma.muhpc.OutputActor], implicit system: akka.actor.ActorSystem)akka.testkit.TestActorRef[org.musigma.muhpc.OutputActor] in object TestActorRef. Unspecified value parameter system. 

I am very new to this. Please help.

+5
source share
1 answer

For all instances of actors, TestActorRef or real-life instances, an ActorSystem is required for placement. Methods that create and run participants (again, testing or otherwise) require an implicit ActorSystem so that the underlying code that creates this actor knows where to put it.

So, given this, you just need to make sure that you add a line of code like this at the beginning of your test code:

 implicit val system = ActorSystem() 
+11
source

Source: https://habr.com/ru/post/1242295/


All Articles