How to set the test case sequence in xUnit

前端 未结 4 1222
温柔的废话
温柔的废话 2020-12-05 12:59

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

4条回答
  •  星月不相逢
    2020-12-05 13:38

    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 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.

提交回复
热议问题