Book Image

Mockito for Spring

By : Sujoy Acharya
Book Image

Mockito for Spring

By: Sujoy Acharya

Overview of this book

Table of Contents (12 chapters)
Mockito for Spring
About the Author
About the Reviewers

Learning unit testing

A test is a measurement of performance of something, or an examination of data; for example, a class test is an assessment of our understanding, to determine whether we can go to the next level or not. We deliver software to our customers, so a test in the software context is the validation of a requirement before the software is delivered to a customer. For example, we need to check whether a valid user can log in to a system, or 1,000 concurrent users can access the system.

A unit test is a fundamental test to quickly assess whether the result of a computation can possibly go wrong or not. It is a straightforward check to verify the basis of the computation result.

Generally, Java code is unit tested using print statements or by debugging the application. Neither of these approaches is correct, and combining production code with testing logic is not good practice. Though it doesn't break the production code, it increases code complexity, degrades readability, and creates...