I’m trying to use ScalaMock with ScalaTest as such:
class MyTest extends TestNGSuite with MockFactory with ProxyMockFactory {
@Test def someTest() = ...
}
However, I get the following compile error with this code:
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 {
^
Looking at the source it looks like ScalaMock’s MockFactory cannot be mixed into TestNGSuite or JUnitSuite. ScalaMock’s documentation is a bit sparse.
Is there any way to use ScalaMock with ScalaTest’s Junit/TestNG support?
Thanks!
I’m afraid that ScalaMock with TestNG isn’t something I’ve tested (TBH, I hadn’t even noticed that ScalaTest had a TestNG runner!).
Can you please report this as an issue on the ScalaMock tracker and I’ll see what I can do. If you can make a small example project that illustrates the problem available, that would be even better 🙂