[英]could not find implicit value for parameter system: akka.actor.ActorSystem
I am creating a unit test case for an Akka Actor using TestActorRef
. 我正在使用
TestActorRef
为Akka Actor创建一个单元测试用例。
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 in creation of actorRef: 在创建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. 我对此很新。 Kindly help.
请帮助。
All instances of actors, TestActorRef
or actual real instances, need an ActorSystem
to reside in. The methods that instantiate and start actors (again, test or otherwise) require an implicit
ActorSystem
to be in scope so that the underlying code creating that actor knows where to put it. 所有actor,
TestActorRef
或实际实例都需要一个ActorSystem
驻留。实例化和启动actor的方法(再次,测试或其他方式)需要一个implicit
ActorSystem
在范围内,以便创建该actor的底层代码知道在哪里把它。
So, taking that into account, you just need to make sure that you add a line of code like this at the start of your test code: 因此,考虑到这一点,您只需要确保在测试代码的开头添加一行代码:
implicit val system = ActorSystem()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.