Tobias Brandt
Tobias Brandt

Reputation: 3413

How do you use ScalaMock with ScalaTest?

I tried the following

import org.scalatest._
import org.scalamock._
import org.scalamock.scalatest._

class TestMock extends FlatSpec with MockFactory with ShouldMatchers {
  "foo" should "bar" in {
    val obj = mock[Object]
    //...
  }
}

and the compiler tells me that the self type of TestMock does not conform to that of MockFactory. So I changed the class to

class TestMock extends FlatSpec with MockFactory with ShouldMatchers {
  self : MockFactory with Suite =>
  "foo" should "bar" in {
    val obj = mock[Object]
    //...
  }
}

and now it complains that mock is not a value.

I'm using scalatest_2.10-2.0.M5b.jar and scalamock-scalatest-support_2.10-3.0.1.jar.

What am I doing wrong?

Upvotes: 2

Views: 698

Answers (1)

Tobias Brandt
Tobias Brandt

Reputation: 3413

Solved it: apparently one needs both the scalamock-core and scalamock-scalatest-support jars. I was assuming it was either one or the other.

Upvotes: 3

Related Questions