【问题标题】:Error using Mockito and Specs2使用 Mockito 和 Specs2 时出错
【发布时间】:2013-09-12 20:32:14
【问题描述】:

我有以下规格:

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"

但是,当我在 sbt 控制台中输入 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] (test:compile) Compilation failed
[error] Total time: 3 s, completed Sep 12, 2013 3:23:41 PM

有人知道这是什么吗?

【问题讨论】:

    标签: scala mockito specs2


    【解决方案1】:

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

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

    【讨论】:

    • 我确认这一点。 specs2 只有几个强制依赖项。所有其他都是可选的,具体取决于您要使用的功能。
    猜你喜欢
    • 1970-01-01
    • 2013-02-04
    • 2019-07-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多