What I like most in JUnit 5

Kasun Dilunika
dtlpub
Published in
2 min readJan 3, 2017
Picture Credit — https://www.slideshare.net/NoopurGupta6/embracing-junit-5-with-eclipse

I am using JUnit for 8 years now, from the day one I started Test Driven Development(TDD). Most of the times I used JUnit with Hamcrest and Mockito. It was great fun !!!

But, after working few years with Jasmine in Javascript world, I feel (not only me :)) that JUnit is missing several good parts an unit test framework should have. Mainly the descriptiveness to the test cases. Either you have to use a descriptive method name — which is very hard to read in camel case, or some comments over the test method. JBehave tried to address that issue, but their effort is to develop a BDD framework.

However, JUnit 5 has finished that long wait. They have introduced a new annotation called @DisplayName to provide some additional description to test class and its test methods.

See, how neat it is? especially when it comes to reporting.

I just discussed a small new addition is JUnit 5 which is something I waited so long to have. New release comes with lots of additions specially to support new Java 8 Functional Programming features. Unlike previous versions of JUnit, JUnit 5 is composed of several different modules from three different sub-projects.

JUnit 5 = JUnit Platform + JUnit Jupiter + JUnit Vintage

Visit http://junit.org/junit5/docs/current/user-guide/ for more details.

--

--

Kasun Dilunika
dtlpub
Editor for

Software Architect at Digital Transformation, NZ