A JUnit 5 test uses the assertions of JUnit 4, whose argument order and messages differ

tx0/java:legacy-assertions-in-jupiterrecommendedwarningmaintainability/testsdepth fastsmell

What it finds

JUnit 4's Assert takes the message first, JUnit 5's Assertions last. Mixing them in JUnit 5 tests keeps a dependency on JUnit 4 and invites messages passed as values.

Reported is an import of org.junit.Assert in a file that imports org.junit.jupiter.api.Test.

From the rule's source, legacy_assertions_in_jupiter.rs.

Example from the rule's tests
import org.junit.jupiter.api.Test;import static org.junit.Assert.assertEquals;tx0 reports: assertions of JUnit 4 class MixedTest {  @Test  void run() {    assertEquals(1, 1);  }}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/java:legacy-assertions-in-jupiter" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/java:legacy-assertions-in-jupiter] reason="..."

tx0 explain tx0/java:legacy-assertions-in-jupiter shows the same in the terminal. Found a false positive? Report it.