0
내 플레이 응용 프로그램이이 같은이있는 경우 :My Play Application의 생성자가 인수를 취합니다. Spec Test에서 조롱 한 인수를 부여하려면 어떻게해야합니까?
class Foo() extends Bar {}
class Application @Inject (f: Foo) extends Controller {
def index = Action { OK("Hi, Foo App") }
}
가 어떻게 MockedFoo 클래스를 받아 내 사양 테스트를 변경하려면 어떻게해야합니까? 도움을
@RunWith(classOf[JUnitRunner])
class MockedFoo() extends Bar {}
class ApplicationTest(implicit ee: ExecutionEnv) extends Specification {
"Sending a GET request to index " should {
"Respond with OK " in new WithApplication { //######## Inject MockedFoo
val response = route(app, FakeRequest(GET, "/")).get
status(response) mustEqual OK
}
}
}
감사 : 내 자신의 요지를
오히려 GuiceModule을하지 마십시오. 너무 간단하게 들리는 것 같아요. 다른 바 구현 (MockedFoo)을 Test의 Application 생성자에 전달해야합니다. Guice 모듈 만이 유일한 방법 일 수는 없습니다! – dlite922
'bind [MyInterface] .to [MyImplementation]'에서'GuiceableModule'로 암시 적으로 변환되므로 아무 것도 할 필요가 없습니다. – rethab
수입 라인은 어디에 있습니까? – dlite922