使用 Mockito 和 Specs2 时出错

2024-01-29

我有以下规格:

import org.specs2.mock.Mockito
import org.specs2.mutable.Specification

class LinkUserServiceSpec extends Specification with Mockito {

  val linkUserService = mock[LinkUserService]

  "The 'LinkUserService' isUserLinked method" should {
      "return false when a previously unlinked userId is passed in for a given service" in {
          linkUserService.isUserLinked("nobody", "YT") returns false

          linkUserService.isUserLinked("nobody", "YT") must beFalse
      }
  }
}

我的 build.sbt 中有以下依赖项:

"org.specs2" %% "specs2" % "2.2" % "test"

但是,当我输入时出现此错误test进入 sbt 控制台:

[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] (test:compile) Compilation failed
[error] Total time: 3 s, completed Sep 12, 2013 3:23:41 PM

有人知道这可能是什么吗?


显然,如果你想将 Mockito 与 Specs2 一起使用,你必须自己提供依赖项,我将以下内容添加到我的 build.sbt 中,事情开始工作:

"org.mockito" % "mockito-all" % "1.9.5"

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用 Mockito 和 Specs2 时出错 的相关文章

随机推荐