From the course: Java: Testing with JUnit
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
DisplayName
- So we have written our first unit tests already. That's great. Let's inspect how we can improve the report that is coming out of this test using display name. Display name is an annotation that allows us to replace a default name with a custom name. This allows us to make the report more descriptive. Let's move over to IntelliJ and first run or test again and have a good look at a default report. Let's run it again. And in the lower left corner, you can see that the tests we're running are having a name of the method. It is a good practice to have descriptive names for our test methods, but it's even nicer to have a little description with spaces and punctuation instead. Here you can see the default names in the lower left corner, but now it's time to show you how to replace that with a custom name. All I have to do is add the annotation at display name on top of our method. And in here we can simply write a…