samedi 30 juillet 2016

Specs2 tests fails under terminal but work under Intellij IDEA

I'm working on Play 2.5 application in Scala and I'm using Specs2 for testing. Here is my test class:

class Entity1ServiceSpec extends Specification with Mockito {
  private val entity1Repository = mock[Entity1Repository]
  private val entity1Service: Entity1Service = new Entity1ServiceImpl(entity1Repository)

  "Create AddedMessage" should {
    "return true" in {
      running(FakeAppBuilder.buildFakeApp) {
        entity1Repository.create(0, "911", "01", 20) returns true
        val result = entity1Service.create(0, "911", "01", 20)
        there was one(entity1Repository).create(0, "911", "01", 20)
        result shouldEqual true
      }
    }

    "return false" in {
      running(FakeAppBuilder.buildFakeApp) {
        entity1Repository.create(1, "911", "01", 10) returns false
        val result = entity1Service.create(1, "911", "01", 10)
        there was one(entity1Repository).create(1, "911", "01", 10)
        result shouldEqual false
      }
    }
  }

}

When I run the tests under Intellij Idea, everything works well but when I run it under the terminal using sbt test it fails with the following stacktrace:

[error] cannot create an instance for class services.Entity1ServiceSpec
[error]   caused by org.mockito.exceptions.misusing.InvalidUseOfMatchersException: 
[error] Misplaced argument matcher detected here:
[error] 
[error] -> at org.specs2.mock.mockito.MockitoMatchers$class.any(MockitoMatchers.scala:45)

Can someone help me to figure out what am I doing wrong?

Aucun commentaire:

Enregistrer un commentaire