Mockito for Spring

Learn all you need to know about the Spring Framework and how to unit test your projects with Mockito
Preview in Mapt

Mockito for Spring

Sujoy Acharya

Learn all you need to know about the Spring Framework and how to unit test your projects with Mockito
Mapt Subscription
FREE
$29.99/m after trial
eBook
$10.50
RRP $14.99
Save 29%
Print + eBook
$24.99
RRP $24.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
$10.50
$24.99
$29.99 p/m after trial
RRP $14.99
RRP $24.99
Subscription
eBook
Print + eBook
Start 30 Day Trial

Frequently bought together


Mockito for Spring Book Cover
Mockito for Spring
$ 14.99
$ 10.50
Mastering Spring Cloud Book Cover
Mastering Spring Cloud
$ 35.99
$ 25.20
Buy 2 for $28.00
Save $22.98
Add to Cart

Book Details

ISBN 139781783983780
Paperback178 pages

Book Description

Mockito is a testing framework that creates external dependencies; this process is called mocking. This book will provide you with the skills you need to successfully build and maintain meaningful unit and integration test cases for Spring Framework code. This book starts with a brief introduction to the Spring Framework, including its components and architecture.

Packed with real-world examples, the book covers how to make Spring code testable and mock container and external dependencies using Mockito. You then get a walkthrough of the steps that will help you in applying Spring 4 Framework features and advanced Spring testing module features in the real world. By the end of the book, you will be a competent software tester with Spring and Mockito.

Table of Contents

Chapter 1: Getting Familiar with the Spring Framework
Getting started with Spring
Exploring the Spring architecture
Learning the Inversion of Control
Printing Hello World
Examining life cycle messages
Working with autowiring and annotations
Working with aspects
Exploring Spring JDBC
Handling a transaction with Spring
Building an MVC application with Spring
Summary
Chapter 2: Working with JUnit and Mockito
Learning unit testing
Working with the JUnit framework
Working with Mockito
Exploring Mockito
Summary
Chapter 3: Working with Spring Tests
Exploring the TestContext framework
Configuring Spring profiles
Mocking an environment
Mocking the JNDI lookup
Using ReflectionTestUtils
Working with annotations
Testing Spring MVC
Mocking the servlet container with MockMvc
Handling transactions in Spring tests
Summary
Chapter 4: Resolving Out-of-container Dependencies with Mockito
Unit testing the web layer
Unit testing the service layer
Unit testing the data access layer
Summary
Chapter 5: Time Travelling with Spring
Discovering the new Spring release
Working with asynchronous tasks
Exploring @RestController
Learning AsyncRestTemplate
Caching objects
Summary

What You Will Learn

  • Uncover the architecture of the Spring testing framework and write integration tests
  • Explore test doubles and work with dummy, spy, fake, stub, and mock objects
  • Mock Spring container dependencies using Mockito
  • Refresh your Spring Framework knowledge
  • Learn about the advanced Spring 4 Framework features
  • Work with the REST controller to build and unit test RESTful web services
  • Cache data with Spring and EhCache

Authors

Table of Contents

Chapter 1: Getting Familiar with the Spring Framework
Getting started with Spring
Exploring the Spring architecture
Learning the Inversion of Control
Printing Hello World
Examining life cycle messages
Working with autowiring and annotations
Working with aspects
Exploring Spring JDBC
Handling a transaction with Spring
Building an MVC application with Spring
Summary
Chapter 2: Working with JUnit and Mockito
Learning unit testing
Working with the JUnit framework
Working with Mockito
Exploring Mockito
Summary
Chapter 3: Working with Spring Tests
Exploring the TestContext framework
Configuring Spring profiles
Mocking an environment
Mocking the JNDI lookup
Using ReflectionTestUtils
Working with annotations
Testing Spring MVC
Mocking the servlet container with MockMvc
Handling transactions in Spring tests
Summary
Chapter 4: Resolving Out-of-container Dependencies with Mockito
Unit testing the web layer
Unit testing the service layer
Unit testing the data access layer
Summary
Chapter 5: Time Travelling with Spring
Discovering the new Spring release
Working with asynchronous tasks
Exploring @RestController
Learning AsyncRestTemplate
Caching objects
Summary

Book Details

ISBN 139781783983780
Paperback178 pages
Read More

Read More Reviews

Recommended for You

Spring Microservices Book Cover
Spring Microservices
$ 39.99
$ 28.00
Spring: Developing Java Applications for the Enterprise Book Cover
Spring: Developing Java Applications for the Enterprise
$ 67.99
$ 47.60
Learning Spring Boot Book Cover
Learning Spring Boot
$ 26.99
$ 18.90
Spring MVC: Designing Real-World Web Applications Book Cover
Spring MVC: Designing Real-World Web Applications
$ 69.99
$ 49.00
Spring Boot Cookbook Book Cover
Spring Boot Cookbook
$ 23.99
$ 16.80
Learning Spring Application Development Book Cover
Learning Spring Application Development
$ 39.99
$ 28.00