【发布时间】:2020-08-03 12:34:47
【问题描述】:
我正在尝试运行以下测试:
import AV_Enums.TimeSeriesFunctions
import org.scalamock.scalatest.MockFactory
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.must.Matchers.{be, _}
import scalaj.http.HttpResponse
import scala.io.Source
class ResponseParserTest extends AnyFunSuite with MockFactory {
test("Parsing from a valid response returns a Right") {
val mockResponse = Source.fromResource("MockResponse.json").mkString
val mockResponse = mock[HttpResponse[String]]
(mockResponse.body _).expects().returning(mockResponse)
ResponseParser.convertTimeSeries(TimeSeriesFunctions.TIME_SERIES_INTRADAY, mockResponse) must be('right)
}
}
但是我收到以下构建错误,我不明白是什么原因:
type mismatch;
found : T
required: String
val mockResponse = mock[HttpResponse[String]]
_ must follow method; cannot follow mockResponse.body.type
(mockResponse.body _).expects().returning(mockResponse)
我确定我在 ScalaMock 的用法上遗漏了一些东西,但我找不到它是什么。
【问题讨论】:
标签: scala mocking scalatest scalamock