openrewrite / openrewrite/rewrite-testing-frameworks
JUnit 5 recipe request: use lambdas for assertion messages that perform computations
Open
Nobody has claimed this yet.
enhancement
recipe
- Dominant language
- Java
- Stars
- 100
- Forks
- 105
- Avg merge
- 2h 25m
- Merged PRs (30d)
- 9
Description
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");
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the requested JUnit 5 transformation and its two examples, then locate the existing JUnit 5 recipe entry points and related tests in the repository. Done means runtime-computed assertion messages are wrapped in lambdas, while compile-time string concatenation remains unchanged, with tests covering both cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100