Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

TimeoutAttribute Class

Definition

Namespace:
Microsoft.VisualStudio.TestTools.UnitTesting
Assembly:
Microsoft.VisualStudio.TestPlatform.TestFramework.dll
Assembly:
MSTest.TestFramework.dll
Assembly:
Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll
Package:
MSTest.TestFramework v1.1.18
Package:
MSTest.TestFramework v1.2.1
Package:
MSTest.TestFramework v1.3.2
Package:
MSTest.TestFramework v1.4.0
Package:
MSTest.TestFramework v2.0.0
Package:
MSTest.TestFramework v2.1.2
Package:
MSTest.TestFramework v2.2.10
Package:
MSTest.TestFramework v3.0.4
Package:
MSTest.TestFramework v3.1.1
Package:
MSTest.TestFramework v3.10.5
Package:
MSTest.TestFramework v3.11.0
Package:
MSTest.TestFramework v3.2.2
Package:
MSTest.TestFramework v3.3.1
Package:
MSTest.TestFramework v3.4.3
Package:
MSTest.TestFramework v3.5.2
Package:
MSTest.TestFramework v3.6.4
Package:
MSTest.TestFramework v3.7.3
Package:
MSTest.TestFramework v3.8.3
Package:
MSTest.TestFramework v3.9.3
Package:
MSTest.TestFramework v4.0.2
Package:
MSTest.TestFramework v4.1.0
Package:
MSTest.TestFramework v4.2.3
Source:
TimeoutAttribute.cs
Source:
TimeoutAttribute.cs
Source:
TimeoutAttribute.cs
Source:
TimeoutAttribute.cs
Source:
TimeoutAttribute.cs
Source:
TimeoutAttribute.cs
Source:
TimeoutAttribute.cs
Source:
TimeoutAttribute.cs
Source:
TimeoutAttribute.cs
Source:
TimeoutAttribute.cs
Source:
TimeoutAttribute.cs
Source:
TimeoutAttribute.cs
Source:
TimeoutAttribute.cs
Source:
TimeoutAttribute.cs

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Timeout attribute; used to specify the timeout of a unit test.

public ref class TimeoutAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple=false)]
public sealed class TimeoutAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Method)]
public sealed class TimeoutAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Method, Inherited=false)]
public sealed class TimeoutAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple=false)>]
type TimeoutAttribute = class
 inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Method)>]
type TimeoutAttribute = class
 inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Method, Inherited=false)>]
type TimeoutAttribute = class
 inherit Attribute
Public NotInheritable Class TimeoutAttribute
Inherits Attribute
Inheritance
TimeoutAttribute
Attributes

Constructors

Name Description
TimeoutAttribute(Int32)

Initializes a new instance of the TimeoutAttribute class.

TimeoutAttribute(TestTimeout)
Obsolete.

Initializes a new instance of the TimeoutAttribute class with a preset timeout.

Properties

Name Description
CooperativeCancellation

Gets or sets a value indicating whether the test method should be cooperatively canceled on timeout. When set to true, the cancellation token is canceled on timeout, and the method completion is awaited. The test method and all the code it calls, must be designed in a way that it observes the cancellation and cancels cooperatively. If the test method does not complete, the timeout does not force it to complete. When set to false, the cancellation token is canceled on timeout, timeout result is reported and the method task will continue running on background. This may lead to conflicts in file access on test cleanup, unobserved exceptions, and memory leaks.

Timeout

Gets the timeout in milliseconds.

Applies to


Feedback

Was this page helpful?