I am trying to see if there is a way to include \"descriptive text\" in my junit reports by way of javadocs. JUnit 4 doesnt seem to support the \'description\' attribute for the
In JUnit 5
there is a way to annotate every test with a @DisplayName
. The declared test classes can have text
, special characters
and emojis
.
The declared text on each test is visible by test runners
and test reports
.
The Javadoc says:
public @interface DisplayName
@DisplayName is used to declare a custom display name for the annotated test class or test method. Display names are typically used for test reporting in IDEs and build tools and may contain spaces, special characters, and even emoji.
And the User Guide:
import org.junit.gen5.api.DisplayName;
import org.junit.gen5.api.Test;
@DisplayName("A special test case")
class DisplayNameDemo {
@Test
@DisplayName("Custom test name containing spaces")
void testWithDisplayNameContainingSpaces() {
}
@Test
@DisplayName("╯°□°)╯")
void testWithDisplayNameContainingSpecialCharacters() {
}
@Test
@DisplayName("