加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

scala – 使用Mockito和Specs2时出错

发布时间:2020-12-16 09:57:44 所属栏目:安全 来源:网络整理
导读:我有以下规格: import org.specs2.mock.Mockitoimport org.specs2.mutable.Specificationclass LinkUserServiceSpec extends Specification with Mockito { val linkUserService = mock[LinkUserService] "The 'LinkUserService' isUserLinked method" shou
我有以下规格:

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

谁知道这可能是什么?

解决方法

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

“org.mockito”%“mockito-all”%“1.9.5”

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读