Skip to content

Configure the mojo unit tests through the plugin testing harness - #276

Merged
slachiewicz merged 1 commit into
masterfrom
agent/plugin-testing-harness
Nov 8, 2026
Merged

slachiewicz merged 1 commit into
masterfrom
agent/plugin-testing-harness

Conversation

@slachiewicz

Copy link
Copy Markdown
Member

AddSkipParametersTest, UpToDatePropertyTest and the multi-setting case of RegexPropertyTest set private mojo fields by reflection, which skips Maven's configuration step. They now use @MojoTest from maven-plugin-testing-harness 3.5.1, as exec, flatten and xml do: each mojo is configured from a small POM in src/test/resources (for the uptodate goals, the configuration of the former ITs), the log is a Mockito spy to verify against, and the reflection helpers and the hand-written recording log are gone. The multi-setting regex case moves to RegexPropertiesMojoTest.

New test dependencies: the harness, Mockito 4.11.0 (still Java 8) and plexus-xml 3.1.0, whose XML classes the harness reads POMs with and plexus-utils 4 no longer contains.

The single-goal uptodate POMs write <elseValue> instead of the parameter's alias <else>: the harness finds an aliased element but does not rename it to the field, so the configurator rejects it, while Maven itself renames it.

Verified: mvn -Prun-its verify on Maven 3.10.0-rc-1 → 0 Checkstyle violations, 101 unit tests (same per-class counts as before) and 33 ITs pass; the converted tests also pass on Zulu 8; disabling the resource skip, inverting the up-to-date timestamp check, or skipping the settings in RegexPropertiesMojo each fails the matching tests.

Part of mojohaus/.github#29

The tests that replaced the parameter-only ITs set private fields by
reflection, which skips Maven's own configuration step. With @MojoTest the
mojos are configured from small POMs, as Maven does, the log is a spy to
verify against, and no reflection helpers remain.
@slachiewicz slachiewicz added the maintenance Cleanup, refactoring or other internal change label Nov 8, 2026
@slachiewicz
slachiewicz marked this pull request as ready for review November 8, 2026 01:34
@slachiewicz
slachiewicz merged commit 7a62172 into master Nov 8, 2026
18 checks passed
@slachiewicz
slachiewicz deleted the agent/plugin-testing-harness branch November 8, 2026 01:48
@github-actions github-actions Bot added this to the 3.7.1 milestone Nov 8, 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