@DisplayName Annotation on Test Class

This lesson demonstrates how to provide custom display names to test class.

We'll cover the following

@DisplayName on Test Class

JUnit 5 has @DisplayName annotation which is used to provide a custom name for the test class. Usually, By default, JUnit 5 reporting prints the class name in the IDE test report and also while executing test cases. We can use @DisplayName annotation to provide a custom name to test class, that makes it easier to read. Thus, it acts as metadata for our test class.

@DisplayName annotation can take up string having the following things:-

  1. It can take spaces between words.
  2. It can take special characters.
  3. It can take emojis as well.

Let’s look at a demo:-

Get hands-on with 1400+ tech skills courses.