You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2022/02/15 17:45:57 UTC
[GitHub] [accumulo] DomGarguilo commented on issue #2441: Migrate from JUnit 4 to JUnit 5
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: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org