I'm trying to write tests for a scala-play application and I got stuck because I can't inject MyService into my class spec (example code below).
//------THE SERVICE I WANT TO INJECT -----------///
class MyService@Inject()(ws: WSClient,
config: Config,
myData1DAO: MyData1DAO,
myData2DAO: MyData2DAO,
myData3DAO: MyData3DAO,
myData4DAO: MyData4DAO,
myData5DAO: MyData5DAO,
myData6DAO: MyData6DAO)(implicit ec: ExecutionContext) {
def methodIWantToCallInTests = ???
}
////------------MY TEST SPEC-------------------/////
class MyTestSpec Inject()(myService: MyService) extends PlaySpec with MockitoSugar {
// DOESNT WORK :(
//
"MyService" should {
"make something good" in {
new MyService( .., .., ..,).methodIWantToCallInTests // TOO LONG :(
}
}
}
Trying to inject MyService as shown in the code doesn't work (and it's even a dumb try probably). The only other thing I was thinking about is to make the "new" of MyService.
Please help even with just a link or book I can find the answer in. Thank you in advanced.
Aucun commentaire:
Enregistrer un commentaire