NUnit SetUpFixture attribute equivalent in xUnit?

时光毁灭记忆、已成空白 提交于 2021-02-07 03:18:56

问题


In nUnit, SetUpFixture allowed me to run some code before any tests. Is there anything like that when using xUnit?


From nUnit documentation:

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.


回答1:


xUnit's comparison table shows that where you would use [TestFixtureSetUp] in NUnit, you make your test fixture class implement IUseFixture<T>.


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:

Note: any testing framework attributes that are not in this list have no corresponding attribute in xUnit.net.




回答2:


This was covered on the xunit forum in this discussion. (And most recently in this question)



来源:https://stackoverflow.com/questions/2986143/nunit-setupfixture-attribute-equivalent-in-xunit

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!