ScalaMock不适用于ScalaTest的TestNG / JUnit支持特征

时间:2012-02-01 22:11:40

标签: scala scalatest

我正在尝试将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的文档有点稀疏。

有没有办法在ScalaTest的Junit / TestNG支持下使用ScalaMock?

谢谢!

1 个答案:

答案 0 :(得分:2)

我担心带有TestNG的ScalaMock不是我测试的东西(TBH,我甚至没有注意到ScalaTest有一个TestNG跑者!)。

你能否在ScalaMock tracker上报告这个问题,我会看到我能做些什么。如果你能做一个小例子项目来说明可用的问题,那就更好了: - )