Scalatest 和 scalamock - 涉及 SuiteMixin 的依赖问题

标签 scala maven mocking dependency-management scalatest

我正在尝试设置我的项目以使用 scalatest 和 scalamock。 我使用的是 scala 版本 2.10.0。
但是,我似乎无法获得正确的依赖关系。

我从这段代码开始:

class  ControllerTest extends org.scalatest.FunSuite 
                      with org.scalamock.scalatest.MockFactory {}

我尝试了两种版本组合:

1)

  • org.scalatest:scalatest_2.10:1.9.1
  • org.scalamock:scalamock-scalatest-support_2.10:3.0.1

这就是我得到的:

scala: bad symbolic reference. 
A signature in MockFactory.class refers to type SuiteMixin in package org.scalatest which is not available. 
It may be completely missing from the current classpath, or the version on the classpath might be incompatible with the version used when compiling MockFactory.class.

注意:在scalamock documentation中,指定的 Artifact id 没有尾随 _2.10,但 maven 找不到任何这样命名的 Artifact 。另外,我在他们的网站上找不到 scalamock 应该使用什么 scalatest 版本。

2)

  1. org.scalatest:scalatest_2.10:1.9.1
  2. org.scalamock:scalamock-scalatest-support_2.10.0-RC5:3.0-M8

编译器说:

scala: overriding method nestedSuites in trait SuiteMixin of type => scala.collection.immutable.IndexedSeq[org.scalatest.Suite];
method nestedSuites in trait Suite of type => List[org.scalatest.Suite] has incompatible type
class ControllerTest extends FunSuite with MockFactory {


scala: class ControllerTest needs to be abstract, since:
it has 5 unimplemented members.
/** As seen from class ControllerTest, the missing signatures are as follows.
 *  For convenience, these are usable as stub implementations.
 */
  def rerunner: Option[String] = ???
  def run(testName: Option[String],args: org.scalatest.Args): org.scalatest.Status = ???
  protected def runNestedSuites(args: org.scalatest.Args): org.scalatest.Status = ???
  protected def runTest(testName: String,args: org.scalatest.Args): org.scalatest.Status = ???
  protected def runTests(testName: Option[String],args: org.scalatest.Args): org.scalatest.Status = ??? 

那么,SuiteMixin 的这个特性是怎么回事?
如果我使用 scalatest-support_2.10.0-RC5:3.0-M8,它似乎存在于 scalatest lib 中。
如果我使用 scalatest-support_2.10:3.0.1,它似乎已经从所述 scalatest 库中消失了。

这是什么法术?而且,更重要的是,我应该使用什么版本组合才能使其工作?

谢谢!

最佳答案

如果你有这种依赖性

"org.scalamock" %% "scalamock-scalatest-support" % "3.0.1" % "test"

它将自动下载正确版本的scalatest。在本例中是

org.scalatest#scalatest_2.10;2.0.M5b!scalatest_2.10.jar

在大多数情况下,一个库依赖于另一个库,您只需添加该库作为依赖项即可。类似 Sbt 的工具将获取其他依赖项。

关于Scalatest 和 scalamock - 涉及 SuiteMixin 的依赖问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15138623/

相关文章:

maven - 同时使用 maven-flatten-plugin 和 maven-shade-plugin

python - 被其他模块使用的假模块

java - Scala - 重写 Scala 类中的 Java 接口(interface)方法

eclipse - eclipse(开普勒):maven插件(m2e,1.4.0):

Scala 过滤器扩展

java - Lombok 未在 .class 文件中生成样板并且找不到任何解决方案

node.js - 如何用 Jest 模拟 express.Application?

c# - 最小起订量无效方法

scala - Monoid 的错误累积

scala - 在 Scala 中修改大文件