5. Why Mocks?
• Help design solution;
• Avoid high coupling;
• Promove high cohesion;
• Easy to use;
• Promove Agile development;
• Improve performance in unit test;
6. Where can I use Mock?
• DataBase;
• WebServices;
• NetWork
• Classes;
13. Mockito API
• Easy to use;
• High learning Curve;
• Excellent Documentation;
• “stub-run-verify” concept;
• Concept stub is separed of verification;
• Clear code;
14. And the others?
• Use “except-run-verify” concept; (it is not good)
• Code is not as clear as Mockito;
• Documentation is not as good as Mockito ‘s doc;
• Verify and expect are bult-in in expect() method;
(Mockito is separated. It is better)
19. Verify
it possible check the number invocation of method
• atLeastOnce(), atLeast(int), atMost(int), never()
verify(mockobject,times(3)).buy(new BigDecimal("10000"))
20. More features
Check Mockito Documentation. There are many
examples.
http://docs.mockito.googlecode.com/hg/org/mockito/
Mockito.html
21. Conclusion
If you want to improve of quality in unit test use
Mock.It will contribute to design, code,
development etc.There are many APIs in
market, but the most used are: EasyMock,
Jmock and Mockito.