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

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

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...