NUnit SetUpFixture 属性在 xUnit 中等效吗? [英] NUnit SetUpFixture attribute equivalent in xUnit?
问题描述
在 nUnit 中,SetUpFixture 允许我在任何测试之前运行一些代码.使用 xUnit 时有没有类似的东西?
In nUnit, SetUpFixture allowed me to run some code before any tests. Is there anything like that when using xUnit?
该属性用于标记一个类,该类包含给定命名空间下所有测试装置的一次性设置或拆卸方法.
This is the attribute that marks a class that contains the one-time setup or teardown methods for all the test fixtures under a given namespace.
推荐答案
xUnit 的 对比表表明,在 NUnit 中使用 [TestFixtureSetUp]
的地方,你的测试夹具类实现了 IUseFixture
.
xUnit's comparison table shows that where you would use [TestFixtureSetUp]
in NUnit, you make your test fixture class implement IUseFixture<T>
.
如果 [TestFixtureSetUp]
不是您要查找的属性,则兼容性表开头的标题表明没有等效项:
If [TestFixtureSetUp]
isn't the attribute you're looking for, then the header at the beginning of the compatibility table indicates that there is no equivalent:
注意:任何不在此列表中的测试框架属性在 xUnit.net 中都没有对应的属性.
Note: any testing framework attributes that are not in this list have no corresponding attribute in xUnit.net.
这篇关于NUnit SetUpFixture 属性在 xUnit 中等效吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!