Skip to content

Move the tests that do not use the plugin testing harness to JUnit 5 and off Hamcrest - #1422

Merged
slachiewicz merged 2 commits into
masterfrom
agent/junit5-plain
Oct 10, 2026
Merged

slachiewicz merged 2 commits into
masterfrom
agent/junit5-plain

Conversation

@slachiewicz

@slachiewicz slachiewicz commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

Part of #1414. Thirteen test classes in versions-maven-plugin use plain JUnit 4 and now use JUnit 5; the module gets junit-jupiter-api like versions-common has. None of them passes a message as the first argument of an assertion, so the argument order is unchanged.

The same classes no longer use Hamcrest. equalTo, is, instanceOf, nullValue and empty become the matching Assertions methods. The text matchers have no JUnit counterpart, so TextAssertions adds assertContains, assertNotContains, assertContainsInOrder, assertMatches (the whole text, as matchesPattern did) and assertAnyLineContains, each printing the text it checked when it fails.

The other 27 JUnit 4 classes use AbstractMojoTestCase and MojoRule, the deprecated classes CI warns about, and keep JUnit 4 and Hamcrest for now: the JUnit 5 MojoExtension of the harness gives the mojo an empty MavenProject instead of building the POM, so those tests need a helper that builds the project first. That comes next under #1414, and the vintage engine and Hamcrest go once they move.

Verified: mvn -pl versions-maven-plugin install -Dinvoker.skip โ†’ 297 tests, the same count as on master, 0 failures, 0 Checkstyle violations; changing an expected value for assertContains, assertNotContains and assertContainsInOrder makes each fail with the checked text

@slachiewicz slachiewicz added the maintenance Cleanup, refactoring or other internal change label Oct 10, 2026
@slachiewicz
slachiewicz marked this pull request as ready for review October 10, 2026 16:31
@slachiewicz slachiewicz changed the title Move the tests that do not use the plugin testing harness to JUnit 5 Move the tests that do not use the plugin testing harness to JUnit 5 and off Hamcrest Oct 10, 2026
@slachiewicz
slachiewicz merged commit 86aea0f into master Oct 10, 2026
15 checks passed
@slachiewicz
slachiewicz deleted the agent/junit5-plain branch October 10, 2026 16:57
@github-actions github-actions Bot added this to the 2.22.1 milestone Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Cleanup, refactoring or other internal change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant