Mockito for Spring

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

Mockito for Spring

This ebook is included in a Mapt subscription
Sujoy Acharya

Learn all you need to know about the Spring Framework and how to unit test your projects with Mockito
$0.00
$14.99
$24.99
$29.99p/m after trial
RRP $14.99
RRP $24.99
Subscription
eBook
Print + eBook
Start 30 Day Trial
Subscribe and access every Packt eBook & Video.
 
  • 4,000+ eBooks & Videos
  • 40+ New titles a month
  • 1 Free eBook/Video to keep every month
Start Free Trial
 
Preview in Mapt

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