PriorityAttribute Class
Definition
- Namespace
- Codebelt.Extensions.Xunit
- Assemblies
- Codebelt.Extensions.Xunit.dll
Assigns a numeric execution priority to a test method when its class uses PriorityTestMethodOrderer.
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public sealed class PriorityAttribute : TraitAttribute, ITraitAttribute
- Inheritance
-
TraitAttributePriorityAttribute
- Implements
-
ITraitAttribute
- Inherited Members
-
TraitAttribute.GetTraits()TraitAttribute.NameTraitAttribute.Value
Examples
The following test checks an initialization step before using the initialized value. The attribute supplies the numeric value consumed by PriorityTestMethodOrderer.
using Codebelt.Extensions.Xunit;
using Xunit;
namespace Example.Tests;
[TestMethodOrderer(typeof(PriorityTestMethodOrderer))]
public class InitializationTest : Test
{
private static string _value;
public InitializationTest(ITestOutputHelper output) : base(output) { }
[Fact, Priority(0)]
public void ShouldInitializeFirst()
{
var priority = new PriorityAttribute(0);
Assert.Equal(0, priority.Priority);
_value = "ready";
}
[Fact, Priority(1)]
public void ShouldReadInitializedValue()
{
Assert.Equal("ready", _value);
}
}
Availability: .NET 11, .NET 10 and .NET Standard 2.0
Constructors
| Name | Description |
|---|---|
| PriorityAttribute(int) | Initializes a new instance of the PriorityAttribute class. |
Properties
| Name | Description |
|---|---|
| Priority | Gets the numeric execution priority. |