JUnit 5 – features

The third and last article of our three part serieson JUnit. This time we look at its features.

6.Using the new JUnit 5 features

The JUnit 5 introduces new annotations, from which we are detailing a few ones.

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


The result of running this test should look like this:



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:



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

Share the knowledge

Luxoft Warsaw - Warsaw Spire, plac Europejski 1, 00-844 Warszawa
Dimitrie Pompeiu nr 5-7 , building C, Et. 5, sect 2, Bucharest, 014459

Contact phone:

021 371 4858
Luxoft Poland Wroclaw - Silver Tower pl. Konstytucji 3-go Maja 3 50-048 Wroclaw
Aleja Generała Tadeusza Bora-Komorowskiego 25, Quattro Business Park Five, 31-476 Kraków, Poland

Contact phone:

+48 122110650
Thank you.
Your request has been received.