DEV Community

Discussion on: Why You Should Start Using JUnit 5

Collapse
 
lukefx profile image
Luca Simone

Why they added a @DisplayName and didn't add a param to @test like @test (name = "it should not fails")?

Collapse
 
stealthmusic profile image
Jan Wedel

Ha! That's a very good question that I just recently asked Sam Brannon, one of the core committers of JUnit 5. :)

His answer goes as follows:

  • There are other "things" that support @DisplayName like test class (as shown in my example), @TestFactory, @RepeatedTest, @ParameterizedTest and @TestTemplate. Having @DisplayName orthogonal to those features is just about separating concern.
  • If JUnit would have a concept like @AliasFor meta annotations in spring, ´this would still be possible (but it doesn't)
  • You could write your own custom composed annotation