Abstract
One thing that makes unit-testing code so hard is the way the real world keeps intruding. If all we had to do was code up tests for methods that sort arrays or generate Fibonacci series, life would be easy. In the real world we have to test code that uses databases, communications devices, user interfaces, and external applications. We might have to interface to devices that are not yet available or simulate network errors that are impossible to generate locally. This all conspires to stop our unit tests from being neat, self-contained (and orthogonal) chunks of code. Fortunately there is a testing pattern that can help. The authors consider the use of mock objects. With mock objects you can test code in splendid isolation, simulating all those messy real-world things that would otherwise make automated testing impossible. As with many other testing practices, the discipline of using mock objects can improve your code's structure.
Talk to us
Join us for a 30 min session where you can share your feedback and ask us any queries you have
Disclaimer: All third-party content on this website/platform is and will remain the property of their respective owners and is provided on "as is" basis without any warranties, express or implied. Use of third-party content does not indicate any affiliation, sponsorship with or endorsement by them. Any references to third-party content is to identify the corresponding services and shall be considered fair use under The CopyrightLaw.