ScalaMock Status Report

Apart from a little work to make it compatible with the most recent versions of Scala and ScalaTest (thanks to Chua Chee Seng, Duncan Crawford and Chris Birchall) ScalaMock has been moribund over the last 12 months. This is partly because my focus has been on writing Seven Concurrency Models in Seven Weeks, but mostly because of insurmountable issues with Scala’s current macro support.

There is good news on both fronts, however. First, I recently finished the book, so I should now have more time to devote to ScalaMock. And second, Eugene has announced Palladium, which looks like it should provide everything that ScalaMock needs.

So where is ScalaMock now? And where is it (hopefully) going?

Where is ScalaMock today?

ScalaMock 3 supports two types of mock, proxy mocks and macro mocks.

Proxy mocks are not type checked and have a slightly less convenient syntax than macro mocks, but they work with any trait and are fully supported.

Macro mocks are type checked and have a nicer syntax than proxy mocks. They work well with most traits, but fail for traits with “complex” type signatures.

The good news is that macro mocks either work or give a compile error (there should be no situations where a macro mock compiles but gives “odd” results). And if you have a trait for which macro mocks don’t work, you can always use a proxy mock instead.

Where is ScalaMock going?

As soon as Palladium is available, I plan to start working on ScalaMock 4. If Palladium delivers on its promise, ScalaMock 4 should be able to mock any trait, no matter how complex its type. In addition, I expect that it will also support:

  • Improved syntax:

    mockObject.expects.method(arguments)

    instead of:

    (mockObject.method _) expects (arguments)
  • Mocking object creation (constructors)
  • Mocking singleton and companion objects (static methods)
  • Mocking final classes and classes with final methods or private constructors

7 Responses to “ScalaMock Status Report”


  1. 1 fracca April 23, 2014 at 10:39 am

    That’s great news! At the moment I have several unresolved issues (one of them which I’ve raised a year ago), which unfortunately prevents me from using ScalaMock instead of MockitoSugar. Do you have any timelines in terms ScalaMock 4? If it’s at least end of 2014, then I’ll have to hold fornow. If its near the summer, then I’ll work around it. Thanks.

    • 2 paulbutcher April 23, 2014 at 10:43 am

      I wish I could give you a definitive answer, Fernando. The timetable is tied firmly to the Palladium timetable. I know that Eugene is very hopeful that Palladium will make quick progress, but I don’t think that there’s a firm timetable yet.

  2. 3 chesmartin December 25, 2014 at 2:36 pm

    Thanks for your work Paul. I do look forward to scala.meta hopefully enabling all the desirable capabilities of ScalaMock 4.

    Is there any documentation for proxy mocks in ScalaMock 3, and perhaps examples of cases where it’s currently necessary? Looking at the scalamock.org site and the Scaladoc as well, I can’t seem to find any.

  3. 7 paulbutcher January 4, 2015 at 3:13 pm

    Yes, the ScalaTest documentation is somewhat out of date 😦 I know that Paweł has been trying to get this updated, but clearly without success so far. I’ll see if I can find out what the status of this is.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s





%d bloggers like this: