Repository navigation
Configure the mojo unit tests through the plugin testing harness - #276
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AddSkipParametersTest,UpToDatePropertyTestand the multi-setting case ofRegexPropertyTestset private mojo fields by reflection, which skips Maven's configuration step. They now use@MojoTestfrom maven-plugin-testing-harness 3.5.1, as exec, flatten and xml do: each mojo is configured from a small POM insrc/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 toRegexPropertiesMojoTest.New test dependencies: the harness, Mockito 4.11.0 (still Java 8) and
plexus-xml3.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 verifyon 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 inRegexPropertiesMojoeach fails the matching tests.Part of mojohaus/.github#29