Class LocalFactAttribute
This custom XUnit Fact attribute will skip unit tests if the environment variable "XUNIT_SKIP_LOCAL_FACT" exists and is set to the string "true"
Note that the original Skip property takes precedence over this attribute, any unit tests with LocalFactAttribute with its Skip property set will always be skipped, regardless of the environment variable content.
Implements
Inherited Members
Namespace: Akka.TestKit.Xunit.Attributes
Assembly: Akka.TestKit.Xunit.dll
Syntax
[XunitTestCaseDiscoverer(typeof(FactDiscoverer))]
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public class LocalFactAttribute : Attribute, IFactAttribute
Properties
| Edit this page View SourceDisplayName
Gets the name of the test to be used when the test is skipped. When null
is returned, will cause a default display name to be used.
Declaration
public string? DisplayName { get; set; }
Property Value
Type | Description |
---|---|
string |
Explicit
Gets a flag which indicates whether the test should only be run explicitly. An explicit test is skipped by default unless explicit tests are requested to be run.
Declaration
public bool Explicit { get; set; }
Property Value
Type | Description |
---|---|
bool |
Skip
Gets the skip reason for the test. When null
is returned, the test is
not skipped.
Declaration
public string? Skip { get; set; }
Property Value
Type | Description |
---|---|
string |
Remarks
Skipping is conditional based on whether Xunit.v3.IFactAttribute.SkipWhen or Xunit.v3.IFactAttribute.SkipUnless is set.
SkipExceptions
Gets exceptions that, when thrown, will cause the test to be skipped rather than failed.
Declaration
public Type[]? SkipExceptions { get; set; }
Property Value
Type | Description |
---|---|
Type[] |
Remarks
The skip reason will be the exception's message.
SkipLocal
The reason why this unit test is being skipped by the LocalFactAttribute. Note that the original Xunit.FactAttribute.Skip property takes precedence over this message.
Declaration
public string? SkipLocal { get; set; }
Property Value
Type | Description |
---|---|
string |
SkipType
Gets the type to retrieve Xunit.v3.IFactAttribute.SkipUnless or Xunit.v3.IFactAttribute.SkipWhen from. If not set, then the property will be retrieved from the unit test class.
Declaration
public Type? SkipType { get; set; }
Property Value
Type | Description |
---|---|
Type |
SkipUnless
Gets the name of a public static property on the test class which returns bool
to indicate whether the test should be skipped (false
) or not (true
).
Declaration
public string? SkipUnless { get; set; }
Property Value
Type | Description |
---|---|
string |
Remarks
This property cannot be set if Xunit.v3.IFactAttribute.SkipWhen is set. Setting both will
result in a failed test.
To ensure compile-time safety and easier refactoring, use the nameof
operator,
e.g., SkipUnless = nameof(IsConditionMet)
.
SkipWhen
Gets the name of a public static property on the test class which returns bool
to indicate whether the test should be skipped (true
) or not (false
).
Declaration
public string? SkipWhen { get; set; }
Property Value
Type | Description |
---|---|
string |
Remarks
This property cannot be set if Xunit.v3.IFactAttribute.SkipUnless is set. Setting both will
result in a failed test.
To avoid issues during refactoring, it is recommended to use the nameof
operator
to reference the property, e.g., SkipWhen = nameof(IsTestSkipped)
.
Timeout
Gets the timeout for test (in milliseconds). When 0
is returned, the test
will not have a timeout.
Declaration
public int Timeout { get; set; }
Property Value
Type | Description |
---|---|
int |
Remarks
WARNING: Using this with Xunit.Sdk.ParallelAlgorithm.Aggressive will result in undefined behavior. Test timing and timeouts are only reliable when using Xunit.Sdk.ParallelAlgorithm.Conservative (or when parallelization is disabled completely).