NUnit Test Run Order

前端 未结 16 1364
名媛妹妹
名媛妹妹 2020-12-02 11:44

By default nunit tests run alphabetically. Does anyone know of any way to set the execution order? Does an attribute exist for this?

16条回答
  •  醉酒成梦
    2020-12-02 12:19

    If you are using [TestCase], the argument TestName provides a name for the test.

    If not specified, a name is generated based on the method name and the arguments provided.

    You can control the order of test execution as given below:

                        [Test]
                [TestCase("value1", TestName = "ExpressionTest_1")]
                [TestCase("value2", TestName = "ExpressionTest_2")]
                [TestCase("value3", TestName = "ExpressionTest_3")]
                public void ExpressionTest(string  v)
                {
                    //do your stuff
                }
    

    Here i used the method name "ExpressionTest" suffix with a number.

    You can use any names ordered alphabetical see TestCase Attribute

提交回复
热议问题