junit provide a lazy fail message description by using a supplier. The supplier is called only if an error occurs, otherwise it is not called.
Assertions.assertTrue(true, () -> "I won't be called");
Assertions.assertTrue(false, () -> "I will be called");
It is useful for at least two reason :
Suggestion, add the same capability to withFailMEssage or overridingErrorMessage, example :
assertThat(response.isError())
.withFailMessage(() -> "my error")
.isFalse();
Replacing withFailMessage() with as() cut time in one of mine test from 4 minutes 34 seconds to 46 seconds.
I'm ok adding this because it can be useful in some cases.
@Mincol just pointing out that as() and withFailMessage() have different purposes.
For others and @joel-costigliola it does. But I wanted to point out how much real world usage of withFailMessage() can be costly. My usage ofas() is not using lambdas, yet it saved nearly 4 minutes.
So time gain must be in eager call to format within withFailMessage()
Can I work on it锛烮 think it's a good idea to improve the performance in some cases. We can discuss further.
Would be great, thanks @Eveneko.
@Mincol Can you provide your test cases? Thank you very much!
Unfortunately it is proprietary software, but I will try to provide equivalent test. ETA next week.
@Mincol Thx
Starting work on this.
@Mincol please sync with @Eveneko who also wanted to work on this. You can do together if you want!
Most helpful comment
Unfortunately it is proprietary software, but I will try to provide equivalent test. ETA next week.