在单元测试中使用testfixture [英] Usage of testfixture in unit test
问题描述
大家好,
将[TestFixture]属性包含在C#中的单元测试类中是可选的吗?我可以看到无论有没有它,单元测试运行正常。如果被排除在外会不同吗?
请澄清
我试过的:
尝试运行单元测试并使用属性,无法找到任何差异
Hi All,
Is it optional to include [TestFixture] attribute to unit test class in C#. I can see that with or without it the unit tests are running fine. Will it make differnce if it is excluded?
Please clarify
What I have tried:
Tried running the unit tests with and wiht out the attribute, unable to find any difference
推荐答案
假设您正在使用NUnit 2.5或更高版本:
Assuming you're using NUnit 2.5 or higher:
从NUnit 2.5开始,TestFixture属性对于非参数化的非通用灯具是可选的,所以只要该类包含至少一个标有Test,TestCase或TestCaseSource属性的方法。
Beginning with NUnit 2.5, the TestFixture attribute is optional for non-parameterized, non-generic fixtures, so long as the class contains at least one method marked with the Test, TestCase or TestCaseSource attribute.
这篇关于在单元测试中使用testfixture的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!