Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scalatest and scalamock - dependency trouble involving SuiteMixin

I'm trying to setup my project to use scalatest and scalamock. I'm using scala version 2.10.0.
However, I cant seem to get the dependencies right.

I've started with this code:

class  ControllerTest extends org.scalatest.FunSuite 
                      with org.scalamock.scalatest.MockFactory {}

I've tried two combinations of versions:

1)

  • org.scalatest : scalatest_2.10 : 1.9.1
  • org.scalamock: scalamock-scalatest-support_2.10 : 3.0.1

This is what I get:

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.

Note: in the scalamock documentation, the artifact id is specified without the trailing _2.10, but maven couldn't find any artifact named like this. Also, I couldn't find on their site what scalatest version should be used with scalamock.

2)

  1. org.scalatest : scalatest_2.10 : 1.9.1
  2. org.scalamock: scalamock-scalatest-support_2.10.0-RC5: 3.0-M8

The compiler says:

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 {

and

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 = ??? 

So, what's up with this SuiteMixin trait?
If I use scalatest-support_2.10.0-RC5:3.0-M8, it appears to exist in scalatest lib.
If I use scalatest-support_2.10:3.0.1, it seems to have gone from said scalatest lib.

What kind of sorcery is this? And, more importantly, what version combination should I use to make it work?

Thanks!

like image 384
teo Avatar asked Feb 18 '23 08:02

teo


2 Answers

If you have this dependency

"org.scalamock" %% "scalamock-scalatest-support" % "3.0.1" % "test"

It will automatically download the correct version of scalatest. In this case it's

org.scalatest#scalatest_2.10;2.0.M5b!scalatest_2.10.jar

In most cases where one library depends upon another you just add only that one library as dependency. Sbt-like tools will get the other dependencies.

like image 195
EECOLOR Avatar answered Apr 27 '23 22:04

EECOLOR


EECOLOR's answer is correct. To elaborate, the cause of the problem was that the ScalaMock version you chose was compiled against a later version of ScalaTest (2.0.M5b) than the one you were explicitly trying to use (1.9.1).

like image 35
Bill Venners Avatar answered Apr 27 '23 21:04

Bill Venners