This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new b8af95e67ef6 chore: add rule to drop public qualifier from test
classes and methods (#24972)
b8af95e67ef6 is described below
commit b8af95e67ef6333495fd355093f2a994378b9230
Author: Guillaume Nodet <[email protected]>
AuthorDate: Tue Jul 21 11:11:58 2026 +0200
chore: add rule to drop public qualifier from test classes and methods
(#24972)
JUnit 5 does not require test classes or methods to be public.
Add an incremental convention to AGENTS.md: new tests must use
package-private visibility, and modified tests should have public
removed from touched declarations — no bulk sweeps.
Co-authored-by: Claude Opus 4.6 <[email protected]>
---
AGENTS.md | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/AGENTS.md b/AGENTS.md
index 0296a6ab61f2..cfdaa97e74d9 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -244,6 +244,42 @@ await().atMost(10, TimeUnit.SECONDS).until(() ->
mock.getReceivedCounter() >= 2)
- Use `untilAsserted` or `until` with a clear predicate — do not replace a
sleep with a
busy-wait loop.
+### Test Visibility: Drop `public` From Test Classes and Methods
+
+JUnit 5 does **not** require test classes or test methods to be `public` —
package-private
+(the default, no modifier) is sufficient and preferred. Removing the
unnecessary `public`
+qualifier reduces visual noise and follows modern JUnit 5 conventions.
+
+**Examples:**
+
+```java
+// Preferred — package-private (no modifier):
+class MyComponentTest extends CamelTestSupport {
+ @Test
+ void testSendMessage() { ... }
+
+ @Override
+ void configure() throws Exception { ... }
+}
+
+// Avoid — unnecessary public:
+public class MyComponentTest extends CamelTestSupport {
+ @Test
+ public void testSendMessage() { ... }
+}
+```
+
+**Rules:**
+
+- New test classes and test methods MUST NOT use the `public` modifier.
+- When modifying an existing test file, remove the `public` modifier from the
class declaration
+ and from any test methods you touch. Do NOT sweep the entire file — only
change what you are
+ already modifying.
+- `@BeforeAll`, `@AfterAll`, `@BeforeEach`, `@AfterEach`, and `@Override`
methods follow the
+ same rule: drop `public` when adding or modifying them.
+- Do NOT create a standalone PR solely to remove `public` from test files in
bulk — apply the
+ convention incrementally as part of other work.
+
### Issue Investigation (Before Implementation)
Before implementing a fix for a JIRA issue, **thoroughly investigate** the
issue's validity and context.