Is it possible to specify the order of tests in Visual Studio C #?

I have several tests in one namespace. I did not use a naming convention like Test1, Test2, ... etc. For each of my unit tests. So, now that I run all the tests, they do not run in the order I want them. Is there a way to order tests?

My tests don't crash unless I run them in a specific order. However, I just wanted to execute them in the order in which they are in my test table.

+5
source share
4 answers

The answer you are looking for is yes. Although I agree with the principles of isolation, there are scenarios in which you need to check the sequence of events. In VS 2010, you can create a new โ€œOrdered Testโ€ for sequentially linking and testing a test suite.

+5
source

Your tests should not be order dependent; which violates the concept of test non-integration. The inability to order tests in Visual Studio is a reflection of this concept.

+8
source

, , - "".

. , , . , :)

+4
source

Visual Studio has a built-in template for ordered tests (provided that you use the MSTest framework). If you open the context menu in a test project, it is available in the New Test menu or directly as the Ordered Test. I have never used this before, but I assume that your tests still run in undefined order if you run all your tests in the solution.

+2
source

All Articles