Working with Mockito
Mockito is an open source mock unit testing framework for Java. In the previous chapter, we read about test doubles and mock objects. Mockito allows mock object creation, verification, and stubbing.
To find out more about Mockito, visit the following link:
http://code.google.com/p/mockito/
Why should you use Mockito?
Automated tests are safety nets. They run and notify the user if the system is broken so that the offending code can be fixed very quickly.
If a test suite runs for an hour, the purpose of quick feedback is compromised. Unit tests should act as a safety net and provide quick feedback; this is the main principle of TDD.
I worked with an environment where when a piece of code is checked-in, the automated tests would run and would take hours to complete. So, a developer had to wait for an hour to check-in the new code unless the previous build/test run was complete. A developer can check-in the code in the middle of a build, but the best practice is to monitor...