gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 20:50:04 24 4
gpt4 key购买 nike

我正在尝试设置我的项目以使用 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com