openrewrite / openrewrite/rewrite-testing-frameworks

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

Open
#453 0 comments 1 reaction 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.