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

teo*_*teo 4 scala mocking dependency-management maven scalatest

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

我已经开始使用这段代码:

class  ControllerTest extends org.scalatest.FunSuite 
                      with org.scalamock.scalatest.MockFactory {}
Run Code Online (Sandbox Code Playgroud)

我尝试了两种版本的组合:

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.
Run Code Online (Sandbox Code Playgroud)

注意:在scalamock文档中,指定了工件id而没有尾随_2.10,但是maven找不到任何这样的工件.此外,我在他们的网站上找不到scalamock应该使用什么最大的版本.

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 {
Run Code Online (Sandbox Code Playgroud)


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 = ??? 
Run Code Online (Sandbox Code Playgroud)

那么,SuiteMixin的特性是什么呢?
如果我使用scalatest-support_2.10.0-RC5:3.0-M8,它似乎存在于scalatest lib中.
如果我使用scalatest-support_2.10:3.0.1,它似乎已经离开了所谓的scalatest lib.

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

谢谢!

EEC*_*LOR 6

如果你有这种依赖

"org.scalamock" %% "scalamock-scalatest-support" % "3.0.1" % "test"
Run Code Online (Sandbox Code Playgroud)

它会自动下载正确版本的scalatest.在这种情况下它是

org.scalatest#scalatest_2.10;2.0.M5b!scalatest_2.10.jar
Run Code Online (Sandbox Code Playgroud)

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