Skip to content

feat: add JUnit 5 + Mockito unit tests for InfoServlet#74

Merged
AndriyKalashnykov merged 1 commit into
masterfrom
feat/servlet-tests
Jun 16, 2026
Merged

feat: add JUnit 5 + Mockito unit tests for InfoServlet#74
AndriyKalashnykov merged 1 commit into
masterfrom
feat/servlet-tests

Conversation

@AndriyKalashnykov

Copy link
Copy Markdown
Owner

Follow-up to #71 — makes make test real (was a no-op), the deferred test-coverage finding.

Changes

  • pom.xmljunit-jupiter 5.14.4 + mockito-core 5.23.0 (test scope), maven-surefire-plugin 3.5.6. Profile-specific testSourceDirectory mirroring the main sources: src/test/java (javax/tomcat9), src/test/java-jakarta (jakarta/tomcat10/11).
  • TestsInfoServletTest (both variants): assert doGet/doPost set text/html;charset=UTF-8 and forward to index.jsp.
  • WAR hygiene — exclude test-classes/ + surefire-reports/ from the WAR (the pre-existing war-plugin webResource copies all of target/, which would otherwise leak test artifacts into ROOT.war).
  • Zero-warning — load mockito-core as an explicit -javaagent via maven-dependency-plugin 3.11.0 (properties goal) → silences the JDK 21+ "Dynamic loading of agents will be disallowed" self-attach warning.
  • Docs — README/CLAUDE.md updated (no longer "no tests configured").

Version choices (fact-checked)

  • JUnit 5.14.4, not 6.x — JUnit 6 requires Java 17, which would break the JDK 11 (tomcat9) matrix leg. 5.x has a Java 8 floor.
  • Mockito 5.23.0 — Java 11 floor, matches the lowest leg.
  • Surefire 3.5.6 — 3.6.0-M1 is a milestone.

Verification

  • 2 tests pass on all 3 profiles and across the JDK matrix bounds (11 and 25).
  • make ci green · WAR verified free of test artifacts · zero warnings on JDK 25.

- pom.xml: junit-jupiter 5.14.4 + mockito-core 5.23.0 (test scope),
  surefire 3.5.6; profile-specific testSourceDirectory (src/test/java for
  tomcat9, src/test/java-jakarta for tomcat10/11) mirroring main sources
- Tests assert doGet/doPost set text/html content-type and forward to
  index.jsp (javax + jakarta variants)
- Exclude test-classes/ + surefire-reports/ from the WAR (the war-plugin
  webResource copies target/, which would otherwise leak test artifacts)
- Load mockito-core as an explicit -javaagent via maven-dependency-plugin
  3.11.0 properties goal — silences the JDK 21+ self-attach agent warning
- README/CLAUDE.md: document the test suite (no longer "no-op")

Verified: 2 tests pass on all 3 profiles AND across the JDK matrix bounds
(11 and 25); make ci green; WAR free of test artifacts; zero warnings.
@AndriyKalashnykov AndriyKalashnykov merged commit 0515b25 into master Jun 16, 2026
9 checks passed
@AndriyKalashnykov AndriyKalashnykov deleted the feat/servlet-tests branch June 16, 2026 04:24
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.

1 participant