ORPP logo
Image from Google Jackets

Mockito Cookbook.

By: Material type: TextTextPublisher: Birmingham : Packt Publishing, Limited, 2014Copyright date: ©2014Edition: 2nd edDescription: 1 online resource (335 pages)Content type:
  • text
Media type:
  • computer
Carrier type:
  • online resource
ISBN:
  • 9781783982752
Subject(s): Genre/Form: Additional physical formats: Print version:: Mockito CookbookDDC classification:
  • 621.3981
LOC classification:
  • TK7887.5.G794 2014eb
Online resources:
Contents:
Intro -- Mockito Cookbook -- Table of Contents -- Mockito Cookbook -- Credits -- About the Author -- About the Reviewers -- www.PacktPub.com -- Support files, eBooks, discount offers and more -- Why Subscribe? -- Free Access for Packt account holders -- Preface -- What this book covers -- What you need for this book -- Who this book is for -- Conventions -- Reader feedback -- Customer support -- Downloading the example code -- Errata -- Piracy -- Questions -- 1. Getting Started with Mockito -- Introduction -- Adding Mockito to a project's classpath -- How to do it... -- See also -- Getting started with Mockito for JUnit -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Getting started with Mockito for TestNG -- Getting ready -- How to do it... -- How it works... -- See also -- Mockito best practices - test behavior not implementation -- Getting ready -- How to do it... -- See also -- Adding Mockito hints to exception messages (JUnit) (Experimental) -- Getting ready -- How to do it... -- How it works... -- Adding additional Mockito warnings to your tests (JUnit) (Experimental) -- How to do it... -- How it works... -- 2. Creating Mocks -- Introduction -- Creating mocks in code -- Getting ready -- How to do it... -- How it works... -- See also -- Creating mocks with annotations -- Getting ready -- How to do it... -- How it works... -- See also -- Creating mocks with a different default answer -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Creating mocks with different default answers with annotations -- Getting ready -- How to do it... -- How it works... -- See also -- Creating mocks with custom configuration -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Creating mocks of final classes with PowerMock -- Getting ready.
How to do it... -- How it works... -- See also -- Creating mocks of enums with PowerMock -- Getting ready -- How to do it... -- How it works... -- See also -- 3. Creating Spies and Partial Mocks -- Introduction -- Creating spies in code -- Getting ready -- How to do it... -- How it works... -- See also -- Creating spies with custom configuration -- Getting ready -- How to do it... -- How it works... -- See also -- Creating spies using annotations -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Creating partial mocks -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Creating partial mocks of final classes with delegatesTo() -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Creating spies of final classes with PowerMock -- Getting ready -- How to do it... -- How it works... -- See also -- 4. Stubbing Behavior of Mocks -- Introduction -- Using argument matchers for stubbing -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Stubbing methods that return values -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Stubbing methods so that they throw exceptions -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Stubbing methods so that they return custom answers -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Stubbing methods so that they call real methods -- Getting ready -- How to do it... -- See also -- Stubbing void methods -- How to do it... -- How it works... -- See also -- Stubbing void methods so that they throw exceptions -- Getting ready -- How to do it... -- How it works... -- See also -- Stubbing void methods so that they return custom answers -- Getting ready -- How to do it.
How it works... -- See also -- Stubbing void methods so that they call real methods -- Getting ready -- How to do it... -- How it works... -- See also -- Stubbing final methods with PowerMock -- Getting ready -- How to do it... -- How it works... -- See also -- Stubbing static methods with PowerMock -- Getting ready -- How to do it... -- How it works... -- See also -- Stubbing object instantiation using PowerMock -- Getting ready -- How to do it... -- How it works... -- See also -- 5. Stubbing Behavior of Spies -- Introduction -- Stubbing methods that return values -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Stubbing methods so that they throw exceptions -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Stubbing methods so that they return custom answers -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Stubbing void methods -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Stubbing void methods so that they throw exceptions -- Getting ready -- How to do it... -- How it works... -- See also -- Stubbing void methods so that they return custom answers -- Getting ready -- How to do it... -- How it works... -- See also -- Stubbing final methods with PowerMock -- Getting ready -- How to do it... -- How it works... -- See also -- 6. Verifying Test Doubles -- Introduction -- Verifying the method invocation count with times() -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Verifying the method invocation count with atLeast() -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Verifying the method invocation count with atMost() -- Getting ready -- How to do it... -- How it works... -- See also.
Verifying that interactions never happened -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Verifying that interactions stopped happening -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Verifying the order of interactions -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Verifying interactions and ignoring stubbed methods -- Getting ready -- How to do it… -- How it works... -- See also -- Verifying the method invocation within the specified time -- Getting ready -- How to do it… -- How it works... -- There's more... -- See also -- 7. Verifying Behavior with Object Matchers -- Introduction -- Using Hamcrest matchers for assertions -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Creating custom Hamcrest matchers -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Using Hamcrest matchers for stubbing and verification -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Using AssertJ for assertions -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Creating custom AssertJ assertions -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Capturing and asserting the argument -- Getting ready -- How to do it... -- How it works... -- See also -- 8. Refactoring with Mockito -- Introduction -- Removing the problems with instance creation -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Refactoring classes that do too much -- Getting ready -- How to do it... -- See also -- Refactoring the classes that use the class casts -- Getting ready -- How to do it... -- See also -- Refactoring the classes that use static methods.
Getting ready -- How to do it... -- See also -- Refactoring the tests that use too many mocks -- Getting ready -- How to do it... -- How it works.. -- There's more… -- See also -- 9. Integration Testing with Mockito and DI Frameworks -- Introduction -- Injecting test doubles instead of beans using Spring's code configuration -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Injecting test doubles instead of beans using Spring's XML configuration -- Getting ready -- How to do it... -- How it works... -- See also -- Injecting test doubles instead of beans using Springockito -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Injecting test doubles instead of beans with Guice -- Getting ready -- How to do it... -- How it works... -- See also -- Injecting test doubles instead of beans with Guice using Jukito -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- 10. Mocking Libraries Comparison -- Introduction -- Mockito versus EasyMock -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Mockito versus JMockit -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Mockito versus JMock -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Mockito versus Spock -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Index.
Summary: This is a focused guide with lots of practical recipes with presentations of business issues and presentation of the whole test of the system. This book shows the use of Mockito's popular unit testing frameworks such as JUnit, PowerMock, TestNG, and so on. If you are a software developer with no testing experience (especially with Mockito) and you want to start using Mockito in the most efficient way then this book is for you. This book assumes that you have a good knowledge level and understanding of Java-based unit testing frameworks.
Tags from this library: No tags from this library for this title. Log in to add tags.
Star ratings
    Average rating: 0.0 (0 votes)
No physical items for this record

Intro -- Mockito Cookbook -- Table of Contents -- Mockito Cookbook -- Credits -- About the Author -- About the Reviewers -- www.PacktPub.com -- Support files, eBooks, discount offers and more -- Why Subscribe? -- Free Access for Packt account holders -- Preface -- What this book covers -- What you need for this book -- Who this book is for -- Conventions -- Reader feedback -- Customer support -- Downloading the example code -- Errata -- Piracy -- Questions -- 1. Getting Started with Mockito -- Introduction -- Adding Mockito to a project's classpath -- How to do it... -- See also -- Getting started with Mockito for JUnit -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Getting started with Mockito for TestNG -- Getting ready -- How to do it... -- How it works... -- See also -- Mockito best practices - test behavior not implementation -- Getting ready -- How to do it... -- See also -- Adding Mockito hints to exception messages (JUnit) (Experimental) -- Getting ready -- How to do it... -- How it works... -- Adding additional Mockito warnings to your tests (JUnit) (Experimental) -- How to do it... -- How it works... -- 2. Creating Mocks -- Introduction -- Creating mocks in code -- Getting ready -- How to do it... -- How it works... -- See also -- Creating mocks with annotations -- Getting ready -- How to do it... -- How it works... -- See also -- Creating mocks with a different default answer -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Creating mocks with different default answers with annotations -- Getting ready -- How to do it... -- How it works... -- See also -- Creating mocks with custom configuration -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Creating mocks of final classes with PowerMock -- Getting ready.

How to do it... -- How it works... -- See also -- Creating mocks of enums with PowerMock -- Getting ready -- How to do it... -- How it works... -- See also -- 3. Creating Spies and Partial Mocks -- Introduction -- Creating spies in code -- Getting ready -- How to do it... -- How it works... -- See also -- Creating spies with custom configuration -- Getting ready -- How to do it... -- How it works... -- See also -- Creating spies using annotations -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Creating partial mocks -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Creating partial mocks of final classes with delegatesTo() -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Creating spies of final classes with PowerMock -- Getting ready -- How to do it... -- How it works... -- See also -- 4. Stubbing Behavior of Mocks -- Introduction -- Using argument matchers for stubbing -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Stubbing methods that return values -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Stubbing methods so that they throw exceptions -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Stubbing methods so that they return custom answers -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Stubbing methods so that they call real methods -- Getting ready -- How to do it... -- See also -- Stubbing void methods -- How to do it... -- How it works... -- See also -- Stubbing void methods so that they throw exceptions -- Getting ready -- How to do it... -- How it works... -- See also -- Stubbing void methods so that they return custom answers -- Getting ready -- How to do it.

How it works... -- See also -- Stubbing void methods so that they call real methods -- Getting ready -- How to do it... -- How it works... -- See also -- Stubbing final methods with PowerMock -- Getting ready -- How to do it... -- How it works... -- See also -- Stubbing static methods with PowerMock -- Getting ready -- How to do it... -- How it works... -- See also -- Stubbing object instantiation using PowerMock -- Getting ready -- How to do it... -- How it works... -- See also -- 5. Stubbing Behavior of Spies -- Introduction -- Stubbing methods that return values -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Stubbing methods so that they throw exceptions -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Stubbing methods so that they return custom answers -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Stubbing void methods -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Stubbing void methods so that they throw exceptions -- Getting ready -- How to do it... -- How it works... -- See also -- Stubbing void methods so that they return custom answers -- Getting ready -- How to do it... -- How it works... -- See also -- Stubbing final methods with PowerMock -- Getting ready -- How to do it... -- How it works... -- See also -- 6. Verifying Test Doubles -- Introduction -- Verifying the method invocation count with times() -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Verifying the method invocation count with atLeast() -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Verifying the method invocation count with atMost() -- Getting ready -- How to do it... -- How it works... -- See also.

Verifying that interactions never happened -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Verifying that interactions stopped happening -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Verifying the order of interactions -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Verifying interactions and ignoring stubbed methods -- Getting ready -- How to do it… -- How it works... -- See also -- Verifying the method invocation within the specified time -- Getting ready -- How to do it… -- How it works... -- There's more... -- See also -- 7. Verifying Behavior with Object Matchers -- Introduction -- Using Hamcrest matchers for assertions -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Creating custom Hamcrest matchers -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Using Hamcrest matchers for stubbing and verification -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Using AssertJ for assertions -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Creating custom AssertJ assertions -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Capturing and asserting the argument -- Getting ready -- How to do it... -- How it works... -- See also -- 8. Refactoring with Mockito -- Introduction -- Removing the problems with instance creation -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Refactoring classes that do too much -- Getting ready -- How to do it... -- See also -- Refactoring the classes that use the class casts -- Getting ready -- How to do it... -- See also -- Refactoring the classes that use static methods.

Getting ready -- How to do it... -- See also -- Refactoring the tests that use too many mocks -- Getting ready -- How to do it... -- How it works.. -- There's more… -- See also -- 9. Integration Testing with Mockito and DI Frameworks -- Introduction -- Injecting test doubles instead of beans using Spring's code configuration -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Injecting test doubles instead of beans using Spring's XML configuration -- Getting ready -- How to do it... -- How it works... -- See also -- Injecting test doubles instead of beans using Springockito -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Injecting test doubles instead of beans with Guice -- Getting ready -- How to do it... -- How it works... -- See also -- Injecting test doubles instead of beans with Guice using Jukito -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- 10. Mocking Libraries Comparison -- Introduction -- Mockito versus EasyMock -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Mockito versus JMockit -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Mockito versus JMock -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Mockito versus Spock -- Getting ready -- How to do it... -- How it works... -- There's more... -- See also -- Index.

This is a focused guide with lots of practical recipes with presentations of business issues and presentation of the whole test of the system. This book shows the use of Mockito's popular unit testing frameworks such as JUnit, PowerMock, TestNG, and so on. If you are a software developer with no testing experience (especially with Mockito) and you want to start using Mockito in the most efficient way then this book is for you. This book assumes that you have a good knowledge level and understanding of Java-based unit testing frameworks.

Description based on publisher supplied metadata and other sources.

Electronic reproduction. Ann Arbor, Michigan : ProQuest Ebook Central, 2024. Available via World Wide Web. Access may be limited to ProQuest Ebook Central affiliated libraries.

There are no comments on this title.

to post a comment.

© 2024 Resource Centre. All rights reserved.