Home > Software design >  Issues with {displayName} of JUnit5 @RepeatedTest
Issues with {displayName} of JUnit5 @RepeatedTest

Time:10-26

It's evening here in Nigeria and I am facing a problem while studying JUnit 5 Repeated tests:

@RepeatedTest(value=4, name= "{displayName} running: {currentRepetition}/{totalRepetitions}")
@DisplayName(”RepeatedTest”)
void repeatedTest() {
        //removed for brevity.
}

In the above code, unlike the other placeholders, {displayName} isn't resolved. Why please?

CodePudding user response:

You forgot to put value in @DisplayName annotation. Try this:

@RepeatedTest(value=4, name= "{displayName} running: {currentRepetition}/{totalRepetitions}")
@DisplayName("MyTestClass")
void repeatedTest() {
        //removed for brevity.
}

Documentation for @DisplayName annotation: enter image description here

  • Related