我有一个服务:
trait MyService extends HttpService {
def getDao(implicit dao: SomeDAO) = dao
def someRoute = path("foo") {
get {
complete(getDao getSomething)
}
}
}
然后,我有一个演员:
class MyActor extends MyService with Actor {
override def receive: Receive = runRoute(someRoute)
def actorRefFactory: ActorRefFactory = context
}
我的测试类如下所示:
class MyServiceTest extends FlatSpec with ScalatestRouteTest with MyService with Matchers with MockFactory {
override implicit def actorRefFactory: ActorSystem = system
implicit val _dao: SomeDAO = mock[SomeDAO]
"My service" should "return something" in {
Get("/foo") ~> someRoute ~> check {
status should be(OK)
}
}
}
但是,当我运行测试,编译器会抱怨,对于内含价值SomeDAO
无法找到。 如何管理以获得SomeDAO
进入我的服务? 我在想什么/我究竟做错了什么?