Skip to content

Move the mojo tests that take their project from a POM to JUnit 5 - #1425

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

slachiewicz merged 2 commits into
masterfrom
agent/junit5-pom-updaters

Conversation

@slachiewicz

@slachiewicz slachiewicz commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

Part of #1414, step 2. The fourteen classes that took their project from a test POM through AbstractMojoTestCase and MojoRule move to ProjectMojoExtension from #1423 and off Hamcrest:

  • goals that rewrite the POM: SetMojoTest, UseDepVersionMojoTest, SetPropertyMojoTest, UpdatePropertiesMojoTest with its base, UpdatePropertyMojoTest, SetScmTagMojoTest, RevertMojoTest, UpdateChildModulesMojoTest;
  • display, report and skip: DisplayDependencyUpdatesMojoTest, DisplayPropertyUpdatesMojoTest, DisplayPluginUpdatesMojoTest, PropertyUpdatesReportTest, CompareDependenciesMojoTest, SkipParameterTest.

These tests pick their POM at run time, copy it themselves and read it back, so the extension gets a lookup from code next to @InjectMojo: ProjectMojos.lookup(goal, pom) and lookupInReactor(goal, baseDir, modules...), taken as a test or @BeforeEach parameter; neither copies the POM. The extension now also does what the JUnit 4 harness did and MojoExtension does not, for both kinds of lookup:

  • the plugin configuration a POM inherits from its parent or plugin management applies (UseDepVersionMojoTest.testPropertyFromParent takes depVersion from the parent);
  • the session has default Settings and a DefaultRepositorySystemSession instead of null;
  • the session's projects are the project, or the modules of a reactor, with all projects being the root followed by the modules;
  • the mojo has a plugin context map instead of null.

testDependenciesMatchTestScope had no @Test and ran only because JUnit 3 picks up every public test* method; it is now annotated. TestUtils.createMavenSession, the last caller of the deprecated MavenSession constructor, TestUtils.fixAllProjects and the Hamcrest matcher in TestIgnoreVersions go with their last callers. TextAssertions gets assertTextNotMatches and assertNoLineContains.

Verified: mvn clean install -Dinvoker.skip → all modules pass, 297 tests in the plugin, the same count as before for each of the fourteen classes, 0 Checkstyle violations

@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 19:09
Base automatically changed from agent/junit5-harness to master October 10, 2026 19:20
… to JUnit 5

ProjectMojos looks up mojos from code, on the project built from a given
POM or reactor, configured like a build would: inherited plugin
configuration, default settings, the session's projects. Part of #1414.
@slachiewicz
slachiewicz force-pushed the agent/junit5-pom-updaters branch from f8eb5e4 to 2d263a1 Compare October 10, 2026 19:25
…a POM to JUnit 5

ProjectMojoExtension also gives mojos a plugin context and the session a
repository session, as the JUnit 4 harness did. testDependenciesMatchTestScope
ran only because JUnit 3 picked up every test* method; it is now annotated.
Part of #1414.
@slachiewicz slachiewicz changed the title Move the mojo tests that take their project from a POM and rewrite it to JUnit 5 Move the mojo tests that take their project from a POM to JUnit 5 Oct 10, 2026
@slachiewicz
slachiewicz merged commit 969078b into master Oct 10, 2026
15 checks passed
@slachiewicz
slachiewicz deleted the agent/junit5-pom-updaters branch October 10, 2026 19:53
@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