![](/img/trans.png)
[英]IO(Http) is cause the error “could not find implicit value for parameter system: akka.actor.ActorSystem”
[英]could not find implicit value for parameter system: akka.actor.ActorSystem
我正在使用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
在创建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.
我对此很新。 请帮助。
所有actor, TestActorRef
或实际实例都需要一个ActorSystem
驻留。实例化和启动actor的方法(再次,测试或其他方式)需要一个implicit
ActorSystem
在范围内,以便创建该actor的底层代码知道在哪里把它。
因此,考虑到这一点,您只需要确保在测试代码的开头添加一行代码:
implicit val system = ActorSystem()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.