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
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Working with the JUnit framework


JUnit is the most popular unit testing framework for Java. It offers a metadata-based, non-invasive, and elegant unit testing framework for the Java community. Apparently, TestNG has cleaner syntax and usage than JUnit, but JUnit is far more popular than TestNG. JUnit enjoys better mocking support such as from Mockito, which offers a custom JUnit4 runner.

Version 4.12 is the latest JUnit framework version that can be downloaded from https://github.com/junit-team/junit/wiki/Download-and-Install.

JUnit 4 is a metadata-based (annotation), non-invasive (JUnit tests do not need to inherit from a framework class) framework. The JUnit framework provides APIs to write test cases to verify the individual functional flows, requirements, or units of code. JUnit evolved from an invasive framework to a non-invasive framework, so we must take a look at previous versions of JUnit framework to understand the benefits of JUnit 4. The following section compares the JUnit 4 framework...