Mocks are used to isolate unit tests against external dependencies. For example, if your class under test depends on an external data access class, you can mock this to provide controlled data and eliminate the need for an external data resource.

The Mockito library is a popular mocking framework for Java. To use it in your tests add a dependency on the mockito-core artifact to your build.sbt file. For example: