我正在尝试将 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 支持一起使用?
谢谢!