How to set the test case sequence in xUnit

前端 未结 4 1223
温柔的废话
温柔的废话 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:44

    Testpriority: at the bottom of this page.

    [PrioritizedFixture]
    public class MyTests
    {
        [Fact, TestPriority(1)]
        public void FirstTest()
        {
            // Test code here is always run first
        }
        [Fact, TestPriority(2)]
        public void SeccondTest()
        {
            // Test code here is run second
        }
    }
    

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

提交回复
热议问题