Skip to content

Bound acceptance tests by the test's CancelAfter budget via an explicit CancellationToken - #5871

Closed
ramonsmits wants to merge 1 commit into
masterfrom
ramon/acceptance-test-timeout-explicit
Closed

ramonsmits wants to merge 1 commit into
masterfrom
ramon/acceptance-test-timeout-explicit

Conversation

@ramonsmits

@ramonsmits ramonsmits commented Sep 9, 2026 •

Copy link
Copy Markdown
Member

Alternative to #5870 without the scenario wrapper. Same motivation: NServiceBus.AcceptanceTesting caps Done at 90 seconds unless Run receives a cancellable token, and the journey tests from #5810 regularly exceed that on Windows runners.

NServiceBusAcceptanceTest carries [CancelAfter(180_000)], which NUnit applies to every derived fixture. Every test that runs a scenario now takes a trailing CancellationToken cancellationToken = default, which NUnit fills from that budget (also for [TestCase] methods), and passes it to Run. The rewrite is mechanical: 282 methods across 195 files, plus forwarding the token to the few ReadAsStringAsync and AssertAuthConfigurationResponse calls CA2016 then flags. A test that already declares [CancelAfter] keeps its own value.

NUnit1027 is suppressed in the acceptance projects: the analyzer only looks for [CancelAfter] on the method and its direct containing class, so it reports the token parameter as unsupplied even though NUnit honours the inherited attribute. Reported upstream as nunit/nunit.analyzers#1019, fix in nunit/nunit.analyzers#1020.

Verified locally: a [CancelAfter(5_000)] test with a never-completing Done is cancelled after 5 s, and Primary, Audit and Monitoring fixtures pass unchanged.

Pairs with #5872: without it a timed-out test reports the TaskCanceledException from the aborted host shutdown instead of the timeout.

…icit CancellationToken

NServiceBus.AcceptanceTesting caps Done at a fixed 90 seconds unless Run is
handed a cancellable token. The multi-step journey tests regularly exceed
that on Windows runners and fail with a timeout while still making progress.

NServiceBusAcceptanceTest now carries [CancelAfter(180_000)], which NUnit
applies to every derived fixture through the execution context. Every test
that runs a scenario takes a trailing CancellationToken, which NUnit fills
from that budget, and passes it to Run. NUnit1027 is suppressed in the
acceptance projects because the analyzer only looks for [CancelAfter] on the
method and its direct containing class, not on base classes.
@ramonsmits

Copy link
Copy Markdown
Member Author

@ramonsmits ramonsmits closed this Sep 10, 2026
@danielmarbach
danielmarbach deleted the ramon/acceptance-test-timeout-explicit branch September 10, 2026 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants