ScalaMock – a native library to mock objects
As we discussed, at instances where we need some other services that we are yet to define or it's harder to create their instances since using them is a matter of complexity, we tend to use some Mocking framework.
ScalaMock is a native framework available in Scala. To include ScalaMock in our project, we'll add a dependency for it in our build.sbt file. Let's do that. We'll add the following line in the build file:
libraryDependencies += "org.scalamock" %% "scalamock" % "4.0.0" % Test
We've specified the test scope, because we're sure that scalamock is only going to be used in our test cases. After writing this dependency, we'll perform an sbt update command by calling the sbt update command in the SBT shell. This update is going to add the scalamock dependency to our project. We can ensure this by taking a look at the external sources folder. There's going to be a dependency with the scalamock name. If that's available there, we are ready to mock...