Skip to content

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

Description

@vlsi

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");

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestrecipeRecipe request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Recipes Wanted

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions