Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JUnit 5 recipe request: use lambdas for assertion messages that perform computations #453

Open
vlsi opened this issue Jan 4, 2024 · 0 comments
Labels
enhancement New feature or request recipe Recipe request

Comments

@vlsi
Copy link

vlsi commented Jan 4, 2024

What problem are you trying to solve?

Sample input:

assertEquals(
  XAException.XAER_PROTO,
  xae.errorCode,
  "Prepare call on already prepared xid " + xid + " expects XAER_PROTO"
);

=>

assertEquals(
  XAException.XAER_PROTO,
  xae.errorCode,
  () -> "Prepare call on already prepared xid " + xid + " expects XAER_PROTO" // <-- this is Supplier<String> now
);

Note that compile-time string concatenation should be ignored.
It is fine to keep the message as is since the concatenation is performed at compile time, and there's no runtime overhead.

assertEquals(
  XAException.XAER_PROTO,
  xae.errorCode,
  "Prepare call on already prepared xid " +
    " expects XAER_PROTO");
@vlsi vlsi added the enhancement New feature or request label Jan 4, 2024
@timtebeek timtebeek added the recipe Recipe request label Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request recipe Recipe request
Projects
Status: Recipes Wanted
Development

No branches or pull requests

2 participants