Mockito Programming Cookbook

About the author

JCGs (Java Code Geeks) is an independent online community focused on creating the ultimate Java to Java developers resource center; targeted at the technical architect, technical team lead (senior developer), project manager and junior developers alike.

JCGs serve the Java, SOA, Agile and Telecom communities with daily news written by domain experts, articles, tutorials, reviews, announcements, code snippets and open source projects.

You can find them online at https://www.javacodegeeks.com/

Mockito is an open source testing framework for Java released under the MIT License. The framework allows the creation of test double objects (mock objects) in automated unit tests for the purpose of Test-driven Development (TDD) or Behavior Driven Development (BDD).

In software development there is an opportunity of ensuring that objects perform the behaviors that are expected of them. One approach is to create a test automation framework that actually exercises each of those behaviors and verifies that it performs as expected, even after it is changed. Developers have created mock testing frameworks. These effectively fake some external dependencies so that the object being tested has a consistent interaction with its outside dependencies. Mockito intends to streamline the delivery of these external dependencies that are not subjects of the test. A study performed in 2013 on 10,000 GitHub projects found that Mockito is the 9th most popular Java library. (Source)

In this ebook, we provide a compilation of Mockito programming examples that will help you kick-start your own web projects. We cover a wide range of topics, from initialization and simple test cases, to integration with JUnit, Maven and other frameworks. With our straightforward tutorials, you will be able to get your own projects up and running in minimum time.

 

Mockito Programming Cookbook includes:

  1. Mockito Tutorial for Beginners
  2. Test-Driven DevelopmentWith Mockito
  3. Mockito Initmocks Example
  4. Mockito Maven Dependency Example
  5. Writing JUnit Test Cases Using Mockito
  6. Mockito: How to mock void method call
  7. Spring Test Mock Example
  8. Mockito Captor Example
  9. Mockito ThenReturn Example
JCG eBooks are professionally designed, downloadable collections of popular JCG content – articles, interviews, presentations, and research – covering the latest software development technologies, trends, and topics.
Back to top button