Skip to content

feat: add comprehensive test coverage using maven-plugin-testing-harness 3.5.1#154

Merged
hazendaz merged 2 commits into
masterfrom
copilot/analyze-test-coverage-add-tests
Apr 12, 2026
Merged

feat: add comprehensive test coverage using maven-plugin-testing-harness 3.5.1#154
hazendaz merged 2 commits into
masterfrom
copilot/analyze-test-coverage-add-tests

Conversation

Copilot AI commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Increases test coverage from 23 tests to 63 tests (+40 new tests) by adding new test classes and extending existing ones. Integrates the maven-plugin-testing-harness 3.5.1 to exercise private @Parameter fields that have no package-private setters.

Changes

New test dependencies (pom.xml)

  • org.apache.maven.plugin-testing:maven-plugin-testing-harness:3.5.1 — testing harness
  • junit:junit:4.13.2 — required at test compile scope (MojoRule implements JUnit 4 TestRule)
  • org.codehaus.plexus:plexus-xml:4.1.1 — provides XmlStreamReader / Xpp3Dom moved out of plexus-utils:4.0+

New test classes

Class Tests What's covered
LineEndingTest 9 All 4 LineEnding enum values, getChars(), values(), valueOf()
XmlOutputFormatTest 7 Constructor defaults (indent, newlines, trimText, padText, keepBlankLines), setKeepBlankLines round-trips
AbstractXmlPluginMojoRuleTest 16 Harness-based tests using MojoRule.setVariableValueToObject to configure private @Parameter fields: tabIndent, lineEnding (CRLF, CR), keepBlankLines, expandEmptyElements, indentSize, suppressDeclaration, omitEncoding, skip; xml-check pass / fail / skip scenarios
src/test/resources/it/pom.xml Minimal Maven POM stub for harness infrastructure

Extended test classes

Class New tests What's added
IOTest +4 hash(File) method coverage; same-content and different-content hash comparisons
FormatUtilTest +4 Direct needsFormatting tests (empty / already-formatted / unformatted); formatInPlace on empty file
XmlCheckPluginTest +1 pluginSkip — verifies skip=true prevents execution even with unformatted files

Harness integration notes

MojoRule (Maven 3 API, JUnit 4 Rule) is adapted for JUnit 5 via a private TestMojoRule extends MojoRule inner class that promotes before()/after() to public, then wires them to @BeforeEach/@AfterEach. The harness is used specifically for its setVariableValueToObject reflection utility, which reaches into private @Parameter fields that have no package-private setters — demonstrating exactly the testing use-case the harness was designed for.

Copilot AI and others added 2 commits April 12, 2026 01:45
…ess 3.5.1

- Add maven-plugin-testing-harness 3.5.1, junit:junit:4.13.2, and plexus-xml:4.1.1 test deps
- LineEndingTest: cover all enum values and getChars() for SYSTEM/LF/CRLF/CR
- XmlOutputFormatTest: cover constructor defaults and keepBlankLines getter/setter
- IOTest: add hash(File) tests for file-based hashing, same-content and different-content scenarios
- FormatUtilTest: add needsFormatting direct tests (empty/formatted/unformatted) and formatInPlace for empty files
- XmlCheckPluginTest: add pluginSkip test
- AbstractXmlPluginMojoRuleTest: 16 harness-based tests covering tabIndent, lineEnding (CRLF/CR),
  keepBlankLines, expandEmptyElements, indentSize, suppressDeclaration, omitEncoding, skip,
  and xml-check pass/fail/skip scenarios

Agent-Logs-Url: https://github.com/hazendaz/xml-format-maven-plugin/sessions/f495bdb7-df11-4ace-9855-bcde912d4562

Co-authored-by: hazendaz <975267+hazendaz@users.noreply.github.com>
@hazendaz hazendaz marked this pull request as ready for review April 12, 2026 02:11
@hazendaz hazendaz merged commit 810b9ba into master Apr 12, 2026
1 check passed
@hazendaz hazendaz deleted the copilot/analyze-test-coverage-add-tests branch April 19, 2026 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants