I use Scala Test to test my level of service. I try my best to get a class of service in my test. My test class is below
class SmsServiceSpec extends BaseSpec with OneAppPerSuite with ScalaFutures {
implicit override lazy val app: FakeApplication = FakeApplication()
"SMS Service" must {
"able to send SMS" in {
val smsService = //not sure how to get instance of class here => app.injector.getInstance[SmsService]
whenReady(smsService.sendSms("9XXXXXXX", "This is test message")) { res =>
res mustBe true
}
}
}
}
Edited code according to @easel
class SmsServiceSpec extends BaseSpec with OneAppPerSuite with ScalaFutures {
"SMS Service" must {
"able to send SMS" in {
@Inject val smsService: SmsService = null //not sure how to get instance of class here => app.injector.getInstance[SmsService]
whenReady(smsService.sendSms("98XXXXXX", "This is test message")) { res =>
res mustBe true
}
}
}
}
I am not sure how to get the SMS service instance in the above code.
Thank,
source
share