ReSharper 2026.1 Help

Code inspection: NUnit. Missing 'CancelAfter' attribute on test method declaration.

This inspection reports NUnit 4 test methods that declare a trailing CancellationToken parameter but do not have a [CancelAfter(...)] attribute on the method or its containing test fixture.

Without CancelAfter, NUnit does not provide the cancellation token automatically. The inspection highlights the CancellationToken parameter to show that the test signature suggests a missing timeout attribute.

Example

using System.Threading; using NUnit.Framework; public class Tests { [Test] public void Should_cancel(CancellationToken ct) { } }
using System.Threading; using NUnit.Framework; public class Tests { [Test] [CancelAfter(1000)] public void Should_cancel(CancellationToken ct) { } }

Quick-fix

The quick-fix adds [CancelAfter(1000)] to the test method and lets you adjust the timeout value.

14 April 2026