It’s better to eliminate, or at least reduce dependencies, as much as possible. You can then temporarily replace essential intrinsic dependencies with stubs or mocks to get rapid feedback from unit tests.
If you’re used to EasyMock, JMock, or Mockito with JUnit, you can readily use them with ScalaTest as well. Let’s explore an example that will illustrate the use of Mockito with ScalaTest.
Let’s start with a series of tests for a score method that’s used in a guessing game. This method will return a total score based on the number of vowels—each vowel will receive one point whereas other characters will earn two points.
In the previous example we used a trait to hold the instance being tested. ScalaTest ...