Monday 14 June 2021

Introduction to junit5

Junit5 is a Java unit testing library, composed of 3 sub-projects.

a.   Junit Platform

b.   Junit Jupiter

c.    Junit Vintage

 


Junit Platform

‘Junit Platform’ is a foundation to launch testing frameworks on the JVM. Using TestEngine API of the Platform, you can develop a custom test framework.

 

Junit Jupiter

Built on top of Junit Platform, it is a combination of new programming model and extension model for writing tests and extensions in Junit5.

 

Vintage

Vintage provides a TestEngine that allows you to run old junit3 and junit4 tests on the platform.

 

Motivation to create junit5 and advantages

a.   First version of junit 4 (4.0) is release in October 2006, after that it keep on evolved by adding features incrementally. As you see, first version of junit4 is created a decade ago. Now a days, testing strategies are more matured. As a developer we are responsible to write unit tests, integration tests and end-to-end tests.

b.   Junit 4 is not a modular artefact. Entire junit code is bundled in single jar. We need a modular test framework. Junit 5 is modular and composed of 3 modules.

Junit5 = Platform + Jupiter + Vintage

c.    Test discovery and test execution are tightly coupled in junit4, which are separated in junit5.

d.   Juit5 is created from scratch using java8, whereas junit4 is built on top of java5.

e.   Junit5 is extensible, it provides an extension API to register extensions declaratively.

f.     Junit 5 is backward compatible, where you can run junit 4 test cases in junit 5.

g.   Junit5 is forward compatible, where you can run Junit 5 test casesin junit 4 environment.


Prerequisite

Junit 5 requires Java8 at runtime.

Previous                                                    Next                                                    Home

No comments:

Post a Comment