Instant Mockito [Instant]


This title is available as an eBook only
Instant Mockito [Instant]
eBook: $12.99
Formats: PDF, PacktLib, ePub and Mobi formats
$11.04
save 15%!
Print & eBook also available on:
Learn in an Instant - Short, Fast, Focused
Overview
Table of Contents
Author
Support
Sample Chapters
  • Learn something new in an Instant! A short, fast, focused guide delivering immediate results
  • Stub methods with callbacks
  • Verify the behavior of test mocks
  • Assert the arguments passed to functions of mocks
  • Create custom argument matchers

Book Details

Language : English
eBook : 66 pages
Release Date : August 2013
ISBN : 1782167978
ISBN 13 : 9781782167976
Author(s) : Marcin Grzejszczak
Topics and Technologies : All Books, Application Development, Instant, Open Source

Table of Contents

Instant Mockito
  • Instant Mockito
    • So, what is Mockito?
      • Using Mockito
      • Integrating Mockito within your existing websites/applications
    • Installation
      • Step 1 – what do I need?
      • Step 2 – attaching JARs to the classpath
      • And that's it
    • Quick start – creating your first unit test with Mockito
      • Step 1 – picking a class that you want to unit test
      • Step 2 – picking a method that you want to unit test
      • Step 3 – creating a unit test class with a properly defined method
      • Step 4 – creating mocks and setting them in the object under testing
      • Step 5 – defining, executing, and verifying mock behavior
    • Top 8 features you need to know about
      • Performing argument matching
      • Stubbing multiple calls
      • Working with void methods and thrown exceptions
      • Stubbing with a custom answer
      • Verifying behavior (including argument capturing, verifying call order, and working with asynchronous code)
      • Doing partial mocking (spying)
      • Reducing boilerplate code with annotations
        • Removing boilerplate code by using MockitoJUnitRunner
        • Removing boilerplate code when you can't use MockitoJUnitRunner
      • Taking advantage of advanced mocks configuration
        • Getting more information on NullPointerException
        • Providing additional interfaces
    • People and places you should get to know
      • Official sites
      • Articles and tutorials
      • Community
      • Blogs
      • Twitter

Marcin Grzejszczak

Marcin Grzejszczak is an experienced Java programmer. He is enthusiastic about clean coding and good design. He has contributed to several open source projects (Drools, Moco, Mockito, Spock, and so on) and to Groovy core. He is the co-organizer of the Warsaw Groovy User Group. He is a member of the Most Valuable Blogger program at DZone and Java Code Geeks.

Marcin is the author of Instant Mockito, Packt Publishing, and Drools Refcard at DZone. You can visit his blog, http://toomuchcoding.blogspot.com, or his home page, http://www.marcin.grzejszczak.pl. Or, you can follow him on Twitter at http://twitter.com/MGrzejszczak.

Sorry, we don't have any reviews for this title yet.

Code Downloads

Download the code and support files for this book.


Submit Errata

Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.

Sorry, there are currently no downloads available for this title.

Frequently bought together

Instant Mockito [Instant] +    Mobile Security: How to Secure, Privatize, and Recover Your Devices =
50% Off
the second eBook
Price for both: $29.45

Buy both these recommended eBooks together and get 50% off the cheapest eBook.

What you will learn from this book

  • Create stubs, mocks, and spies
  • Perform argument matching
  • Work with void methods and thrown exceptions
  • Perform stubbing with a custom answer
  • Verify the behaviour of mocks
  • Perform argument capturing
  • Verify the call order
  • Work with asynchronous code
  • Learn about partial mocking
  • Reduce boilerplate code with annotations
  • Learn about advanced mock configuration

In Detail

Mockito is an open source testing framework for Java that automates unit tests for use in test-driven development (TDD) or behavior-driven development (BDD), decoupling test code from the system under test by eliminating the expect-run-verify pattern. It lets you write beautiful tests with a clean and simple API.

Instant Mockito contains plenty of real-life examples on how to unit test your code. It shows you how to use this testing framework and explains best practices on how to use it effectively.

Instant Mockito helps you break each significant method into a set of practical examples. It will clarify all the concepts of unit testing and Mockito.

You will learn how to properly capture and verify arguments passed into your stubbed methods. We will also take a look at verifying an order and returning custom answers on the stubs. If you want to take advantage of using the Mockito framework’s API to tame your code base, then this is the book for you.

You will learn everything you need to know to unit test your code in a clear, readable, and high quality manner.

Approach

Filled with practical, step-by-step instructions and clear explanations for the most important and useful tasks. This is a standard, tutorial-based guide using plenty of examples for illustration.

Who this book is for

Instant Mockito is ideal for developers new to unit testing, who are looking to get to know how to create high quality tests using Mockito. It’s assumed that you will have some experience in Java already.

Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Resources
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software