无法解析游戏框架 2.6.17 中的模拟 [..]



我想模拟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.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, "/"))

它给了我一个错误,它无法解决模拟[...]。 有什么办法解决这个问题吗?

我敢打赌你想执行以下操作:

val reactiveMongoApi: ReactiveMongoApi = mock[ReactiveMongoApi]

最新更新