O'Reilly logo

Scala Test-Driven Development by Gaurav Sood

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Summary

There is a love-hate relationship between developers and mock objects. On the one hand, there are obvious benefits of being able to test classes in isolation. This also evolves into a more loosely coupled architecture and there is greater reusability of code.

On other hand, mocks couple the test code to the actual implementation of the class being tested. If the test code undergoes some major refactoring, it might result in changes in the expectations and verifications of the mocks in the test. This deviates from the principle of the segregation of test and application code.

A mocking framework is a great tool in your development arsenal if rightly used. There is definitely such a thing as too much mocking, so steer clear away from it.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required