Proxy mock objects with ScalaMock isn't working the way its documented or I'm an idiot ( which is a real possibility )

228 views
Skip to first unread message

Andrew

unread,
Nov 7, 2011, 11:43:11 PM11/7/11
to scalatest-users
Hello,

There isn't a ScalaMock google group so this group seemed most
appropriate to seek assistance.

I have a spec set up thusly,

import org.scalatest.WordSpec
import org.scalatest.matchers.{ShouldMatchers, MustMatchers}
import org.scalamock.scalatest.MockFactory

class MyServiceTests extends WordSpec with ShouldMatchers with
MockFactory with MustMatchers {

"MyService" should {
"do some rad stuff" in {
val myMock = mock[MyService]

// yada yada
}
}
}

I get a compile error that says "value not found: mock". The blog only
has instructions for generated mocks. I don't need generated mocks and
would prefer to use proxy mocks. Are there any examples or tips anyone
can point me towards for help on proxy mocks with ScalaMock?

I am using sbt 0.11, ScalaMock 2.0 and ScalaTest 1.6.1 and Scala 2.9.1

I am including ScalaMock with this line in my build.

"org.scalamock" %% "scalamock-scalatest-support" % "2.0"

Any tips would be much appreciated.

Thanks,
Andy

nvo

unread,
Nov 20, 2011, 4:08:59 PM11/20/11
to scalatest-users
Hello,

I currently trying out ScalaMock too.
To use proxy mocks, you have to mix in ProxyMockFactory additionaly to
the MockFactory.
But as I had to learn, proxy mocks sadly can only mock traits and
functions, no classes.

Regards,
Nicolas

Paul Butcher

unread,
Nov 21, 2011, 8:29:39 AM11/21/11
to scalate...@googlegroups.com
On 20 Nov 2011, at 21:08, nvo wrote:
> But as I had to learn, proxy mocks sadly can only mock traits and
> functions, no classes.


Sorry - I clearly need to make this clearer in the documentation. I'll try to do so :-)

Thanks!

--
paul.butcher->msgCount++

Snetterton, Castle Combe, Cadwell Park...
Who says I have a one track mind?

http://www.paulbutcher.com/
LinkedIn: http://www.linkedin.com/in/paulbutcher
MSN: pa...@paulbutcher.com
AIM: paulrabutcher
Skype: paulrabutcher

Reply all
Reply to author
Forward
0 new messages