0

我正在尝试将 ScalaMock 与 ScalaTest 一起使用:

class MyTest extends TestNGSuite with MockFactory with ProxyMockFactory {

  @Test def someTest() = ...
}

但是,我收到以下代码的编译错误:

ERROR: MyTest.scala: error: overriding method runTests in trait TestNGSuite of type 
       (testName: Option[String], reporter: org.scalatest.Reporter, stopper: org.scalatest.Stopper, 
       filter: org.scalatest.Filter, configMap: Map[String, Any], distributor: Option[org.scalattest.Distributor], 
       tracker: org.scalatest.Tracker)Unit;
INFO: method runTests in trait MockFactory of type (testName: Option[String], 
      reporter: org.scalatest.Reporter, stopper: org.scalatest.Stopper, filter: org.scalatest.Filter, 
      configMap: Map[String,Any], distributor: Option[org.scalatest.Distributor],
      tracker: org.scalatest.Tracker)Unit cannot overrride final member;
ERROR: other members with override errors are runTest
INFO: class MyTest extends TestNGSuite with MockFactory with ProxyMockFactory {
            ^

查看源代码,看起来 ScalaMock 的 MockFactory 不能混入 TestNGSuite 或 JUnitSuite。ScalaMock 的文档有点稀疏。

有什么方法可以将 ScalaMock 与 ScalaTest 的 Junit/TestNG 支持一起使用?

谢谢!

4

1 回答 1

2

恐怕带有 TestNG 的 ScalaMock 不是我测试过的东西(TBH,我什至没有注意到 ScalaTest 有一个 TestNG 运行器!)。

您能否将其报告为ScalaMock 跟踪器上的问题,我会看看我能做什么。如果您可以制作一个说明问题的小示例项目,那就更好了:-)

于 2012-02-02T10:13:34.420 回答