Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Learning Modular Java Programming

You're reading from   Learning Modular Java Programming Explore the power of modular programming for building applications with Java and Spring!

Arrow left icon
Product type Paperback
Published in Jun 2016
Publisher Packt
ISBN-13 9781785888823
Length 226 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
 Jog Jog
Author Profile Icon Jog
Jog
Arrow right icon
View More author details
Toc

Mock testing


The testing which is carried out with the help of mock objects is called mock testing. There are a number of ways which provide the means for mock testing. Let's discover them one by one.

Spring testing framework

Spring provides an API to conduct testing using the mock technique in JUnit. Using this API, we can create mock objects of Request, Response, Filter, and HttpSession, which is otherwise available from the container. All those methods which are dependent on request or user's request and response can now be tested easily without a container. Using this API, tests can be created even before the development of the controller has been completed with mocking or stubbing.

Let's use it in our controller testing which we developed in Ch_05_jdbcTemplate_Transaction_Declarative as per the following cases:

Case1 – Inserting contact with correct values as per validation rules

Let's now write mock testing for the AddController with the help of the following steps to find out how mock...

lock icon The rest of the chapter is locked
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Learning Modular Java Programming
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Modal Close icon
Modal Close icon