Mockito is a popular open source mocking framework for Java code. In this article, Marcin Grzejszczak explains how you can use Mockito by adding it to different paths. You will also learn how to implement new tests by using Mockito hints and warnings.
The key features offered by Mockito for mocking Java code are:
* You can either stub or verify the mock behavior without expectation
* You can mock both interfaces and classes
* You can produce little boilerplate code with annotations
* You can easily stub using intuitive argument matchers
The article starts by explaining the differences between the different types of test doubles. Then you learn how to add Mockito to a project classpath and the integration between Mockito and Junit and TestNG java open source unit testing tools. The end of the article lists some of the Mockito best practices. This is a practice-oriented article with a lot of interesting “how to” material on how to effectively use Mockito for unit testing your Java code.
Read the complete article on https://www.packtpub.com/books/content/getting-started-mockito