<PackageReference Include="NUnit" Version="4.2.1" />

TimeoutAttribute

Applies a timeout in milliseconds to a test. When applied to a method, the test is cancelled if the timeout is exceeded. When applied to a class or assembly, the default timeout is set for all contained test methods.
using NUnit.Framework.Interfaces; using NUnit.Framework.Internal; using System; using System.Runtime.CompilerServices; namespace NUnit.Framework { [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = false)] [Obsolete(".NET No longer supports aborting threads as it is not a safe thing to do. Update your tests to use CancelAfterAttribute instead")] public class TimeoutAttribute : PropertyAttribute, IApplyToContext { private readonly int _timeout; public TimeoutAttribute(int timeout) : base(timeout) { _timeout = timeout; } [System.Runtime.CompilerServices.NullableContext(1)] void IApplyToContext.ApplyToContext(TestExecutionContext context) { context.TestCaseTimeout = _timeout; } } }