The leading testing framework for Java unit tests
Part 1 · Analyzing Why Test Cancellation Is Ignored While @BeforeEach Runs
Part 2 · Adding Cancellation Checks to the Jupiter Lifecycle and Opening a PR
Part 3 · Addressing the First Review and Structuring Cancellation Checks with shouldContinue
Part 4 · Writing the Release Note, Addressing the Maintainer’s Review, and Getting Merged
Writing the Release Note
Before the full review came in, I had to update the release notes, but when I was originally working on it, the release notes didn’t exist yet, so I mentioned that in the review, and I got word that the maintainer had created the release notes in response.

Checking the 6.2.0-M2 Release Notes
Let’s check it right away
[[v6.2.0-M2]]
== 6.2.0-M2
*Date of Release:* ❓
*Scope:* ❓
For a complete list of all _closed_ issues and pull requests for this release, consult the
link:{junit-framework-repo}+/milestone/123?closed=1+[6.2.0-M2] milestone page in the JUnit
repository on GitHub.
[[v6.2.0-M2-junit-platform]]
=== JUnit Platform
[[v6.2.0-M2-junit-platform-bug-fixes]]
==== Bug Fixes
* ❓
[[v6.2.0-M2-junit-platform-deprecations-and-breaking-changes]]
==== Deprecations and Breaking Changes
* ❓
[[v6.2.0-M2-junit-platform-new-features-and-improvements]]
==== New Features and Improvements
* ❓
[[v6.2.0-M2-junit-jupiter]]
=== JUnit Jupiter
[[v6.2.0-M2-junit-jupiter-bug-fixes]]
==== Bug Fixes
* `@DefaultLocale` now also restores the default locale of each `Locale.Category`.
[[v6.2.0-M2-junit-jupiter-deprecations-and-breaking-changes]]
==== Deprecations and Breaking Changes
* ❓
[[v6.2.0-M2-junit-jupiter-new-features-and-improvements]]
==== New Features and Improvements
* ❓ // ---- this is my spot ----
[[v6.2.0-M2-junit-vintage]]
=== JUnit Vintage
[[v6.2.0-M2-junit-vintage-bug-fixes]]
==== Bug Fixes
* ❓
[[v6.2.0-M2-junit-vintage-deprecations-and-breaking-changes]]
==== Deprecations and Breaking Changes
* ❓
[[v6.2.0-M2-junit-vintage-new-features-and-improvements]]
==== New Features and Improvements
* ❓
What I found a bit interesting is that it uses AsciiDoc? rather than a regular markdown file. It was my first time seeing it, and apparently it has more of the features needed for technical documentation.
The Release Note I Added
[[v6.2.0-M2-junit-jupiter-new-features-and-improvements]]
==== New Features and Improvements
* Test execution cancellation is now also checked between before callbacks and
lifecycle methods such as `@BeforeAll` and `@BeforeEach` methods.
Since the label on issue #6268, which I took on, was type: enhancement, I put it under New Features and Improvements, and since only Jupiter-side code changed, I add it to junit-jupiter!
I wasn’t sure how much to write, but looking at previous release notes, I saw that most of them are kept short at around two lines, so I followed that (these notes are what JUnit users will read)
The Maintainer’s Full Review

The main review finally came! Roughly, it said
the implementation looks solid, but it seems a few tests are missing, so I was asked to add them!
Request 1: Adding New Tests
- When cancelled in a
BeforeTestExecutionCallback: check that the test method is not invoked and thatAfterTestExecutionCallbackand@AfterEachrun - When cancelled during
PER_CLASSinstance creation : check thatBeforeAllCallbackand the@BeforeAllmethods are skipped and the class is reported as aborted
PER_CLASS is a setting that decides when and how many test instances are created. By default it’s set to PER_METHOD, which creates a new object for every test - when set to PER_CLASS, only one object is created per class and all the tests share it
- When cancelled in a
BeforeClassTemplateInvocationCallback: the first invocation should be aborted without invoking the remainingBeforeClassTemplateInvocationCallbacks and without registering any test methods +AfterClassTemplateInvocationCallbackshould be invoked + the second invocation should be skipped with the reason “Execution cancelled” + the class template container itself should finish successfully
It’s easiest to think of @ClassTemplate as the class version of @ParameterizedTest (running the same test method several times with only the inputs changed). It bundles all the tests in the class and runs them as a whole several times (invocations)
Request 2: Strengthening an Existing Test
Add @AfterAll to CancelledInBeforeAllMethodTestCase and check that it gets called => In JUnit the After layer is basically the cleanup stage, so rather than carefully deciding whether it should be called or not, it’s safer to just call all of it and clean up the resources that were created

Finally Merged
And after that, without any further requests, it got merged!!

Wrapping Up the Contribution
It was a process short and yet long enough to milk write 4 blog posts out of!
Contributing for the first time, I felt a certain sense of accomplishment, and going through the review process, I feel I learned a lot from the two maintainers, from writing code with consistency for the reader in mind, to structural improvements that take test reproducibility into account, to testing the exact expected behavior when testing a feature, so it was truly meaningful
A Side Note: Why Do Maintainers Accept Outside Contributions
As a side note, a thought I had while contributing was: the maintainers must understand this open source project most accurately, so why do they accept contributions from others?! (No hidden meaning, pure curiosity!) So I looked it up (Claude told me), and apparently besides a lack of manpower, there’s also the reason of growing long-term contributors!
After hearing that, I saw the maintainers’ reviews in a new light, and thinking back on how each review pinpointed exactly what to improve and why that improvement was needed, I came to want to contribute to JUnit even more!
- PR: junit-framework#6281: Check for cancellation in Jupiter lifecycle methods
- Issue: junit-framework#6268: Consider test cancellation not only during
prepare