From the course: Complete Guide To Java Testing with JUnit 5 & Mockito
Unlock the full course today
Join today to access over 24,900 courses taught by industry experts.
Add a display name to your tests
From the course: Complete Guide To Java Testing with JUnit 5 & Mockito
Add a display name to your tests
- [Instructor] JUnit 5 comes with many new annotations that can help us improve the clarity and quality of our tests. One of these annotations is display name. Display name allows you to specify custom display names for your test methods. In the past, this might have been done with an assertion message, but the assertion message is only displayed if the assertion fails. A display name is different because it's always shown, regardless of whether the test passes or fails. We can add one at the top of the method. Addition should return correct sum. This feature helps you provide more descriptive names to your tests, making your test reports easier to understand. It can serve as documentation for what each test is intended to check, which can be invaluable for future maintenance. Let's run it and see the display name. In the output, we can see our display name for the addition test. Sometimes you might not need a display name, because the test name is descriptive enough. In the case…
Contents
-
-
-
-
-
-
-
(Locked)
Add a display name to your tests1m 30s
-
(Locked)
Nested tests3m 31s
-
(Locked)
Timeout1m 47s
-
(Locked)
AssertTimeout2m 31s
-
(Locked)
AssertAll3m 50s
-
(Locked)
Message suppliers2m 3s
-
(Locked)
Assumptions API2m 57s
-
(Locked)
TempDir7m 15s
-
(Locked)
Migrate from JUnit 4 to JUnit 52m 52s
-
(Locked)
Challenge: Sorting algorithm validation55s
-
(Locked)
Solution: Sorting algorithm validation6m 47s
-
(Locked)
-
-
-
-