Test-Driven Development with Mockito

Learn how to apply Test-Driven Development and the Mockito framework in real life projects, using realistic, hands-on examples
Preview in Mapt

Test-Driven Development with Mockito

Sujoy Acharya

1 customer reviews
Learn how to apply Test-Driven Development and the Mockito framework in real life projects, using realistic, hands-on examples
Mapt Subscription
FREE
$29.99/m after trial
eBook
$16.80
RRP $23.99
Save 29%
Print + eBook
$39.99
RRP $39.99
What do I get with a Mapt Pro subscription?
  • Unlimited access to all Packt’s 5,000+ eBooks and Videos
  • Early Access content, Progress Tracking, and Assessments
  • 1 Free eBook or Video to download and keep every month after trial
What do I get with an eBook?
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with Print & eBook?
  • Get a paperback copy of the book delivered to you
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with a Video?
  • Download this Video course in MP4 format
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
$0.00
$16.80
$39.99
$29.99p/m after trial
RRP $23.99
RRP $39.99
Subscription
eBook
Print + eBook
Start 30 Day Trial

Frequently bought together


Test-Driven Development with Mockito Book Cover
Test-Driven Development with Mockito
$ 23.99
$ 16.80
Test-Driven iOS Development with Swift 4 - Third Edition Book Cover
Test-Driven iOS Development with Swift 4 - Third Edition
$ 31.99
$ 22.40
Buy 2 for $34.30
Save $21.68
Add to Cart
Subscribe and access every Packt eBook & Video.
 
  • 5,000+ eBooks & Videos
  • 50+ New titles a month
  • 1 Free eBook/Video to keep every month
Start Free Trial
 

Book Details

ISBN 139781783283293
Paperback172 pages

Book Description

The usual life cycle of code involves adding code, breaking an existing functionality, fixing that and breaking a new area! This fragility can be fixed using automated tests and Test Driven Development.

TDD’s test first approach expedites the development process and unit tests act as safety nets for code refactoring and help in maintaining and extending the code. This makes TDD highly beneficial for new projects.

This practical, hands-on guide provides you with a number of clear, step-by-step exercises that will help you to take advantage of the real power that is behind Test Driven Development and the Mockito framework. By using this book, you will gain the knowledge that you need to use the Mockito framework in your project.

This book explains the concept of Test Driven Development (TDD), including mocking and refactoring, as well as breaking down the mystery and confusion that surrounds the test first approach of TDD. It will take you through a number of clear, practical examples that will help you to take advantage of TDD with the Mockito framework, quickly and painlessly.

You will learn how to write unit tests, refactor code and remove code smells. We will also take a look at mock objects and learn to use Mockito framework to stub, mock, verify and spy objects for testability. You will also learn to write clean, maintainable, and extensible code using design principles and patterns.

If you want to take advantage of using Test Driven Development and learn about mocking frameworks, then this is the book for you. You will learn everything you need to know to apply Test Driven Development in a real life project, as well as how to refactor legacy code and write quality code using design patterns.

Table of Contents

Chapter 1: Getting Familiar with TDD
Definition of test
The big picture
Refactoring
Summary
Chapter 2: Refactoring – Roll the Dice
Refactoring
Summary
Chapter 3: Applying TDD
Understanding different test types
Understanding TDD – a real-life example
Summary
Chapter 4: Understanding the Difference between Inside-out and Outside-in
Understanding outside-in
Understanding inside-out
Summary
Chapter 5: Test Doubles
Categories of test doubles
Summary
Chapter 6: Mockito Magic
An overview of Mockito
Qualities of unit testing
Drinking Mockito
Verifying redundant invocation
The argument matcher
Throwing exceptions
Consecutive calls
Stubbing with callbacks – using the Answer class
Spying objects
Using doReturn()
Working with Void methods
Argument capture
Summary
Chapter 7: Leveraging the Mockito Framework in TDD
Applying Mockito
Summary
Chapter 8: World of Patterns
Characteristics of a bad design
Design principles
Design patterns
Summary
Chapter 9: TDD, Legacy Code, and Mockito
What is legacy code?
Problems with legacy code
Diving into the legacy puzzle
Refactoring legacy code
The role of Mockito
Summary

What You Will Learn

  • Create your first unit test and discover the power of unit testing
  • Familiarize yourself with Test-first Development and the refactoring process
  • Add new features to your project applying Test Driven Development
  • Create readable, maintainable, and extensible software using design principles and patterns
  • Start stubbing, mocking, spying, and verifying objects using Mockito APIs
  • Apply inside-out and outside-in TDD styles
  • Expedite the development process using Eclipse and keyboard shortcuts
  • Apply JUnit 4.0 and advanced Mockito features – argument captor, callbacks, and answers

Authors

Table of Contents

Chapter 1: Getting Familiar with TDD
Definition of test
The big picture
Refactoring
Summary
Chapter 2: Refactoring – Roll the Dice
Refactoring
Summary
Chapter 3: Applying TDD
Understanding different test types
Understanding TDD – a real-life example
Summary
Chapter 4: Understanding the Difference between Inside-out and Outside-in
Understanding outside-in
Understanding inside-out
Summary
Chapter 5: Test Doubles
Categories of test doubles
Summary
Chapter 6: Mockito Magic
An overview of Mockito
Qualities of unit testing
Drinking Mockito
Verifying redundant invocation
The argument matcher
Throwing exceptions
Consecutive calls
Stubbing with callbacks – using the Answer class
Spying objects
Using doReturn()
Working with Void methods
Argument capture
Summary
Chapter 7: Leveraging the Mockito Framework in TDD
Applying Mockito
Summary
Chapter 8: World of Patterns
Characteristics of a bad design
Design principles
Design patterns
Summary
Chapter 9: TDD, Legacy Code, and Mockito
What is legacy code?
Problems with legacy code
Diving into the legacy puzzle
Refactoring legacy code
The role of Mockito
Summary

Book Details

ISBN 139781783283293
Paperback172 pages
Read More
From 1 reviews

Read More Reviews

Recommended for You

Mastering Web Application Development with AngularJS Book Cover
Mastering Web Application Development with AngularJS
$ 26.99
$ 5.40
Jenkins Continuous Integration Cookbook Book Cover
Jenkins Continuous Integration Cookbook
$ 26.99
$ 18.90
Apache Maven 3 Cookbook Book Cover
Apache Maven 3 Cookbook
$ 23.99
$ 16.80
Java 7 Concurrency Cookbook Book Cover
Java 7 Concurrency Cookbook
$ 29.99
$ 21.00
Java EE 7 Developer Handbook Book Cover
Java EE 7 Developer Handbook
$ 35.99
$ 25.20
Learning Spring Boot Book Cover
Learning Spring Boot
$ 26.99
$ 18.90