DomGarguilo commented on issue #2441:
URL: https://github.com/apache/accumulo/issues/2441#issuecomment-1040587134
In JUnit 5, the assert statements can accept a `Supplier<String>` as an
alternative to `String` for the message to supply if the assert fails. For
example:
```java
Supplier<String> message = () -> "Calculator.add(2, 2) test failed";
assertEquals(3, Calculator.add(2, 2), message);
```
or equivalently
```java
assertEquals(3, Calculator.add(2, 2), () -> "Calculator.add(2, 2) test
failed");
```
This has the benefit of being lazily evaluated so the string will only be
created when the message is needed rather than always being created. I am
wondering if this possible performance gain is worth the possible (small)
decrease in readability/increase in code complexity. This could be something we
standardize while the migration of JUnit 4 to 5 takes place since we need to
change the order of the assert parameters when there is a message anyways.
Anyone have any thoughts on this?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]