I have written the xUnit test cases in C#. That test class contains so many methods. I need to run the whole test cases in a sequence. How can I set the test case sequence in xUnit?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
In xUnit 2.* this can be achieved using the
TestCaseOrderer
attribute to designate an ordering strategy, which can be used to reference an attribute that is annotated on each test to denote an order.For example:
Ordering Strategy
Attribute
Test Cases
xUnit 2.* ordering samples here
You can't, by design. It's deliberately random in order to prevent anyone getting one of those either by desire or by accident.
The randomness is only for a given Test class, so you may be able to achieve your goals by wrapping items you want to control the order of inside a nested class - but in that case, you'll still end up with random order whenever you have more than two Test Methods in a class.
If you're trying to manage the building up of fixtures or context, the built-in
IUseFixture<T>
mechanism may be appropriate. See the xUnit Cheat Sheet for examples.But you really need to tell us more about what you're trying to do or we'll just have to get speculative.
Testpriority: at the bottom of this page.
BTW, I have the same problem right now. And yes, it is not the clean art.. but QA wanted a manual test.. so an automated test with a specific order already is a big leap for them.. (cough) and yes, it is not really unit testing..