Question

I'm trying to run the following code in a test class in my play application to test 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")
    }
  }
}

I got it from this article: http://workwithplay.com/blog/2013/08/07/mocking-with-mockito/

However when I run 'test' in the play terminal, I get the following error message:

[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

The same problem is described here: Error using Mockito and Specs2, however this sollution doesn't change anything for me.

What does this error message mean exactly? And how do I solve this problem?

The version of play I use is: 2.1.2

Was it helpful?

Solution

"org.mockito" % "mockito-core" % "1.9.5" needs to be added to the list of dependencies.

See the Play documentation on dependencies on how to do that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top