Scala 无法解析playframework 2.6.17中的模拟[…]
我想模拟ReactiveMongoAPI,为此我编写了以下代码Scala 无法解析playframework 2.6.17中的模拟[…],scala,playframework,Scala,Playframework,我想模拟ReactiveMongoAPI,为此我编写了以下代码 package controllers import org.scalatest.mockito.MockitoSugar import org.scalatestplus.play._ import org.scalatestplus.play.guice._ import play.api.test.Helpers._ import play.api.test._ import play.modules.reactivemon
package controllers
import org.scalatest.mockito.MockitoSugar
import org.scalatestplus.play._
import org.scalatestplus.play.guice._
import play.api.test.Helpers._
import play.api.test._
import play.modules.reactivemongo.ReactiveMongoApi
/**
* Add your spec here.
* You can mock out a whole application including requests, plugins etc.
*
* For more information, see https://www.playframework.com/documentation/latest/ScalaTestingWithScalaTest
*/
class HomeControllerSpec extends PlaySpec with GuiceOneAppPerTest with Injecting with MockitoSugar {
val reactiveMongoApi: mock[ReactiveMongoApi]
"HomeController GET" should {
"render the index page from a new instance of controller" in {
val controller = new HomeController(stubControllerComponents(), reactiveMongoApi)
val home = controller.index().apply(FakeRequest(GET, "/"))
它给我的错误是它无法解析mock[…]。
有什么办法可以解决这个问题吗?我打赌您希望按以下步骤进行:
val reactiveMongoApi: ReactiveMongoApi = mock[ReactiveMongoApi]