How to create a TestActorRef inside a test class for an Actor with constructor params?

女生的网名这么多〃 提交于 2019-12-07 03:15:29
negative

I had the same issue because I was using a companion object to inject the config into MyActor without passing it explicitly:

object MyActor {
  def apply(): MyActor = new MyActor(MyActorConfig.default)
  val props = Props(new MyActor(MyActorConfig.default))
}

Then I can just do:

val myActorRef = system.actorOf(MyActor.props, "actorName")

The error is related to passing the arguments explicitly in the test here:

TestActorRef(new DoubleAuctionMarket(google, ticker))

I would try to remove the with BasicMatchingEngine as vptheron said, use the constructor without mixing anything else. Try also with an argument less actor if that is not enough.

That must fix your problem since there are no issues with just:

TestActorRef(new DoubleAuctionMarket(google, ticker))
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!