Description
Summary
I am suggesting an enhancement to allow developers to set priority or execution order for methods within a single test class. Currently, there is no built-in way to control the execution order of test methods in a class, which can be critical for certain test scenarios.
At present, we have a test class with multiple test methods as shown below:
[TestClass]
public class ExampleTests
{
[TestMethod]
public async Task Get_Return_3()
{
//tests
}
[TestMethod]
public async Task Get_Return_1()
{
//tests
}
[TestMethod]
public async Task Get_Return_2()
{
//tests
}
}
}
In this scenario, there is no control over the execution order of the test methods. The .NET documentation provides a way to order unit tests using the Priority attribute, but it is somewhat cumbersome and not very intuitive.
https://learn.microsoft.com/en-us/dotnet/core/testing/order-unit-tests?pivots=mstest
I propose adding a simple attribute that allows setting the execution priority for each test method within a class. Here is an example of how it might look:
[TestClass]
public class ExampleTests
{
[TestMethod]
[Priority(1)]
public async Task Get_Banner_Return_3()
{
//tests
}
[TestMethod]
[Priority(2)]
public async Task Get_Banner_Return_1()
{
//tests
}
[TestMethod]
[Priority(3)]
public async Task Get_Banner_Return_2()
{
//tests
}
}
}
Activity