我正在尝试在我的播放应用程序的测试类中运行以下代码来测试Mockito:
trait DateWSClient {
def currentDate: String
}
class DateProvider (dateWS: DateWSClient) {
def currentYear = {
dateWS.currentDate.split("/")(0)
}
}
import org.specs2._
import org.specs2.mock.Mockito
class DateProviderSpec extends mutable.Specification with Mockito {
"currentYear" should {
"be the first part of the date returned by the WS" in {
val clientMock = mock[DateWSClient]
val formatter = new DateProvider(clientMock)
clientMock.currentDate returns "2013/08/07"
formatter.currentYear must beEqualTo("2013")
}
}
}
我从这篇文章中得到了它:http://workwithplay.com/blog/2013/08/07/mocking-with-mockito/
但是当我在播放终端中运行'test'时,我收到以下错误消息:
[error] bad symbolic reference. A signature in MocksCreation.class refers to type MockSettings
[error] in package org.mockito which is not available.
[error] It may be completely missing from the current classpath, or the version on
[error] the classpath might be incompatible with the version used when compiling MocksCreation.class.
[error] bad symbolic reference. A signature in MockitoStubs.class refers to term stubbing
[error] in package org.mockito which is not available.
[error] It may be completely missing from the current classpath, or the version on
[error] the classpath might be incompatible with the version used when compiling MockitoStubs.class.
[error] two errors found
此处描述了同样的问题:Error using Mockito and Specs2,但这种解决方案对我没有任何改变。
此错误消息的确切含义是什么?我该如何解决这个问题?
我使用的游戏版本是:2.1.2
答案 0 :(得分:2)
"org.mockito" % "mockito-core" % "1.9.5"
添加到依赖项列表中。
请参阅Play documentation on dependencies了解如何操作。