-
Notifications
You must be signed in to change notification settings - Fork 253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Controlling execution order of unit tests #3162
Comments
Hi @shayan0v0n, I think it makes sense to add this support. We would need to have it under some feature flag to avoid potential breaking change for users. |
agree with this |
I have investigated a little more the current code and the test name order is not even respected. As for the ordering itself, in MSTest we have 3 behaviors to respect:
We had a couple of discussions internally and multiple requests to bring back support for ordered tests and I think this is also falling in the same bucket. Rather than rushing on an implementation, I would prefer to go for a more generic solution that would fit the various use cases. Moving out of the current iteration so we can work on the design. |
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:
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:
The text was updated successfully, but these errors were encountered: