Skip to content

Commit ebc273b

Browse files
authored
Clarify test throws guidance (#18066)
1 parent 6813781 commit ebc273b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

.github/agents/knowledge/testing-general-patterns.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
Do not declare multiple checked exception types on a test method.
1919
- Be as specific as possible. Prefer the narrowest single checked type that the test body
2020
actually exposes instead of broad forms such as `throws Exception` or a multi-exception list.
21+
- Apply this guidance only to JUnit test entry points such as `@Test`,
22+
`@ParameterizedTest`, `@RepeatedTest`, `@TestFactory`, and `@TestTemplate`.
23+
Do **not** rewrite nearby helpers or utilities solely to narrow a test method's `throws`
24+
clause, and do not apply this rule to every method in a testing module or abstract test base.
2125
- If the test only blocks on `Future.get(...)` / `CompletableFuture.get(...)`, prefer refactoring to
2226
`join()` or another non-checked wait path when that keeps the test clear, rather than widening the
2327
test method to `throws Exception` just to avoid a multi-exception `throws` clause.

0 commit comments

Comments
 (0)