使用 Mockito 和 Specs2 时出错 [英] Error using Mockito and Specs2

查看:61
本文介绍了使用 Mockito 和 Specs2 时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下规格:

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 中的以下依赖项:

And the following dependency in my build.sbt:

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

但是,当我在 sbt 控制台中键入 test 时出现此错误:

However I get this error when I type test into the sbt console:

[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 中并开始工作:

Apparently if you want to use Mockito with Specs2 you have to provide the dependency yourself, I added the following to my build.sbt and things started working:

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

这篇关于使用 Mockito 和 Specs2 时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆