JUnit 5 – features
JUnit 5 – features
The third and last article of our three part serieson JUnit. This time we look at its features.
23 жов 2018
2770
Інші статті
How to debug and solve the issue of Datanodes which were reported as Bad nodes?
How to incrementally migrate the data from RDBMS to Hadoop using Sqoop Incremental Last Modified technique?
How to implement Slowly Changing Dimensions(SCD) Type 2 in Spark?
How to incrementally migrate the data from RDBMS to Hadoop using Sqoop Incremental Append technique?
Why MongoDB don't fetch all the matching documents for the query fired
How to solve the issue of full disk utilization in HDFS Namenode
Can We Use HDFS as Back-up Storage?
How to do Indexing in MongoDB with Elastic Search? Part 1
How to do Indexing in MongoDB with Elastic Search? Part 2
How to store data on browser using NoSQL IndexedDB?
6.Using the new JUnit 5 features
The JUnit 5 introduces new annotations, from which we are detailing a few ones.
@DisplayName
- It can be used over class and test method.
- It declares a custom display name for the annotated test class or test method.
- It is typically used for test reporting in IDEs and build tools
- It may contain spaces, special characters, and even emoji.

@Nested
Nested tests give the test writer more capabilities to express the relationship among several group of tests. It is a replacement for Enclosed rule, and part of an experimental API.
Inner classes can be:
- Package private
- Non-static
The result of running these tests is:

Conclusions
JUnit 5 comes with a new architecture and with new concepts and annotations. It has addressed the shortcomings of JUnit 4 and provided the developer the possibility to write more expressive and well organized hierarchy of tests. We have explored the most important news, including here the new architecture and the most important newly introduced annotations. The reader should have an overall image of the new capabilities and, from here, new steps can be made in the search of what JUnit 5 can provide. From what this article does not analyze, assertions, assumptions, dynamic and parameterized tests may be the next logical areas to investigate.
Interested in JUnit? Check out our trainings.
Catalin Tudose
Java and Web Technologies Expert