课程: Complete Guide To Java Testing with JUnit 5 & Mockito

今天就学习课程吧!

今天就开通帐号,24,600 门业界名师课程任您挑!

Add a display name to your tests

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…

内容