Skip to content

[Misc] Make JUnit5 test classes and methods package-private (SonarCloud java:S5786)#5826

Open
vmassol wants to merge 1 commit into
masterfrom
claude/vigilant-dirac-0y3zww
Open

[Misc] Make JUnit5 test classes and methods package-private (SonarCloud java:S5786)#5826
vmassol wants to merge 1 commit into
masterfrom
claude/vigilant-dirac-0y3zww

Conversation

@vmassol

@vmassol vmassol commented Jul 13, 2026

Copy link
Copy Markdown
Member

Summary

Mechanical, behaviour-preserving cleanup of SonarCloud rule java:S5786 ("JUnit5 test classes and methods should have default package visibility") across 13 modules. 27 issues fixed in 27 test files (55 public modifiers removed).

JUnit5 no longer requires test classes or test methods to be public; package-private is the recommended visibility.

Details

For every flagged test file the public modifier was removed from:

  • the test class declaration (and any nested @Nested / helper class declarations), and
  • every method whose contiguous preceding annotation block contains a JUnit annotation (@Test, @BeforeEach, @AfterEach, @BeforeAll, @AfterAll, @ParameterizedTest, etc.).

Other modifiers (e.g. static on @BeforeAll methods) and non-JUnit members were left untouched — in particular XWiki-specific lifecycle methods such as @BeforeComponent public void configure(...) keep their visibility (they are not flagged by S5786). No production code changed; only test visibility modifiers.

Modules touched: xwiki-platform-annotation-core, xwiki-platform-csrf, xwiki-platform-display-html, xwiki-platform-livedata-livetable, xwiki-platform-localization-source-jar, xwiki-platform-mentions-notifications, xwiki-platform-notifications-api, xwiki-platform-notifications-filters-default, xwiki-platform-refactoring-default, xwiki-platform-search-solr-embedded, xwiki-platform-security-authentication-default, xwiki-platform-security-authorization-api, xwiki-platform-user-resource.

All fixed issues belong to SonarCloud rule java:S5786. See the open S5786 issues for this project.

Test plan

  • mvn clean install -Plegacy,snapshot -DskipTests across all 13 modules in one reactor — BUILD SUCCESS. Test sources still compile and Checkstyle passes; visibility-only changes are behaviour-preserving.

🤖 Generated with Claude Code


Generated by Claude Code

…ud java:S5786)

Mechanical, behaviour-preserving cleanup of SonarCloud rule java:S5786 across
13 modules: JUnit5 no longer requires test classes or test methods to be public,
package-private is the recommended visibility.

Co-Authored-By: Vincent Massol <vincent@massol.net>
@vmassol vmassol added the llm-agent To be used for PRs created autonomously by LLM agents. label Jul 13, 2026 — with Claude
@vmassol vmassol self-assigned this Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

llm-agent To be used for PRs created autonomously by LLM agents.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant