Table of Contents

Class StaTheoryAttribute

Namespace
Xunit
Assembly
Xunit.StaFact.dll

Identifies an xunit theory that starts on an STA thread. Tests will be Skipped on non-Windows operating systems.

[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
[XunitTestCaseDiscoverer(typeof(StaTheoryDiscoverer))]
public class StaTheoryAttribute : TheoryAttribute, _Attribute, ITheoryAttribute, IFactAttribute
Inheritance
FactAttribute
TheoryAttribute
StaTheoryAttribute
Implements
ITheoryAttribute
IFactAttribute
Inherited Members
TheoryAttribute.DisableDiscoveryEnumeration
TheoryAttribute.SkipTestWithoutData
FactAttribute.DisplayName
FactAttribute.Explicit
FactAttribute.Skip
FactAttribute.SkipExceptions
FactAttribute.SkipType
FactAttribute.SkipUnless
FactAttribute.SkipWhen
FactAttribute.SourceFilePath
FactAttribute.SourceLineNumber
FactAttribute.Timeout

Remarks

The test does not apply a SynchronizationContext, so an async test will resume on a standard MTA thread from the thread pool. To get an STA thread even after awaiting expressions, use UITheoryAttribute.

Constructors

StaTheoryAttribute(string?, int)

Initializes a new instance of the StaTheoryAttribute class.

public StaTheoryAttribute(string? sourceFilePath = null, int sourceLineNumber = -1)

Parameters

sourceFilePath string
sourceLineNumber int