Skip to content

Commit 34b3b85

Browse files
authored
Fix typo and links in cancelafter.md
1 parent 50721b1 commit 34b3b85

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

docs/articles/nunit/writing-tests/attributes/cancelafter.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
1+
---
2+
uid: cancelafterattribute
3+
---
4+
15
# CancelAfter
26

37
Normally, NUnit simply runs tests and waits for them to terminate -- the test is allowed to run indefinitely. For
48
certain kinds of tests, however, it may be desirable to specify a timeout value.
59

610
For .NET Core and later,
7-
[`Thread.Abort`](https://learn.microsoft.com/en-us/dotnet/api/system.threading.thread.abort?view=net-7.0) as used by the
8-
[`TimeoutAttribue`](./timeout.md) can no longer be used, and there is therefore no way to interrupt an endless loop.
11+
[`Thread.Abort`](https://learn.microsoft.com/en-us/dotnet/api/system.threading.thread.abort?view=net-8.0) as used by the
12+
[`TimeoutAttribute`](./timeout.md) can no longer be used, and there is therefore no way to interrupt an endless loop.
913

1014
For all tests, one could use the `--blame-hang(-timeout)` options of [`dotnet
1115
test`](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-test#options). However, this will stop any further
1216
execution of the remaining tests.
1317

1418
To still be able to cancel tests, one has to move to cooperative cancellation. See [Cancellation in Managed
1519
Threads](https://learn.microsoft.com/en-us/dotnet/standard/threading/cancellation-in-managed-threads) using a
16-
[`CancellationToken``](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken?view=net-7.0).
20+
[`CancellationToken``](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken?view=net-8.0).
1721

1822
The `CancelAfterAttribute` is used to specify a timeout value in milliseconds for a test case. If the test case runs
1923
longer than the time specified, the supplied `CancellationToken` is set to canceled. It is however up to the test code
@@ -60,3 +64,6 @@ public async Task PotentiallyLongRunningTest(string uri, CancellationToken token
6064
> When debugging a unit test, i.e. when a debugger is attached to the process, the timeout is not enforced.
6165
6266
## See Also
67+
68+
* [Timeout Attribute](./timeout.md)
69+
* [MaxTime Attribute](./maxtime.md)

0 commit comments

Comments
 (0)