I'm planning on using ScalaTest to test Play Controllers, but still undecided if I should mock with Mockito or ScalaMock. The Play website mentions Mockito, however it seems to focus on Java. ScalaMock looks more natural when developing applications in Scala, however from what I read it seems to support fewer test scenarios compared to Mockito, and it's also less mature. Any suggestions?
2 Answers
The Play website mentions Mockito, however it seems to focus on Java.
Mockito was written for Java but that does not stop it being a very effective tool in Scala projects and is used pretty extensively in the Scala community I believe.
I have used both but tend to use Mockito when I have a choice since I tend to prefer the syntax a little more - but this is more personal preference. Mockito has been around a lot longer than ScalaMock and is much more actively maintained because of it's much larger contributor base.
Have a play around with both first off, or else if you are unsure I would personally just go with Mockito.
I do try and check my design frequently in order to check that I really need those mocks however - it's good practice as I'm sure you are aware.

- 4,614
- 24
- 34
Always happy to look at feature requests on ScalaMock if you think something material is missing. One benefit of ScalaMock is probably the leaner syntax, especially when mocking scala.Function* types.

- 967
- 6
- 16