Skip to content

Commit 6babacb

Browse files
committed
Code review guidance: more explicit about deferAfterAll
1 parent 58a77f9 commit 6babacb

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

.github/agents/code-review-and-fix.agent.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,10 @@ Auto-fix boundaries:
233233
readers/writers/streams/response bodies).
234234
Do not apply this conversion in non-JUnit helper methods, `@BeforeAll`, or shared
235235
setup code.
236+
- class-scoped resources created in `@BeforeAll` or other shared setup — prefer
237+
`AutoCleanupExtension` with `deferAfterAll(...)` over nested `@AfterAll` cleanup
238+
chains. Do not introduce or keep `AutoCleanupExtension` solely for a single
239+
`deferAfterAll(...)` call — use a plain `@AfterAll` instead.
236240
- `hasAttributesSatisfying(...)` calls in test assertions — replace with
237241
`hasAttributesSatisfyingExactly(...)` because it is more precise (the non-exact
238242
variant silently ignores unexpected attributes)

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,8 @@
2929
over wrapping most of the test body in try-with-resources.
3030
- For resources created in `@BeforeAll` or other class-scoped setup, prefer
3131
`AutoCleanupExtension` with `deferAfterAll(...)` over nested `@AfterAll` cleanup
32-
chains. Prefer a single `@AfterAll` when `AutoCleanupExtension` is not otherwise present
33-
or needed in the class. Do **not** introduce `AutoCleanupExtension` solely to call
34-
`deferAfterAll(...)` once on a single resource — a plain `@AfterAll` is cleaner in that
35-
case.
32+
chains. Do not introduce or keep `AutoCleanupExtension` solely for a single
33+
`deferAfterAll(...)` call — use a plain `@AfterAll` instead.
3634
- Reuse an existing `cleanup` extension when one is already in scope.
3735
Otherwise, add a `@RegisterExtension` field when the deferred-cleanup pattern improves
3836
clarity or avoids wrapping most of the test body.

0 commit comments

Comments
 (0)