NUnit是否支持类似于可应用于静态方法的Microsoft.VisualStudio.TestTools.UnitTesting.AssemblyCleanupAttribute的程序集拆解的概念?
该程序将在组件中的所有测试完成后运行。我目前正在使用NUnit 2.6.0。
最佳答案
事实证明,此功能确实存在于NUnit中,但不是很明显或直观。
根据查理·普尔(Charlie Poole)在我为此功能here提出的功能请求中,他指出以下内容将起作用,这是他的直接引述。
Decorate a class outside of any namespace with [SetUpFixture]. Decorate a method of that class with [TearDown]. If you like, decorate another with [SetUp].
Differences from what you are asking for:
The name makes it a little unobvious in this usage.
NUnit allows any number of these and calls them all, without any guarantee of ordering. This is by design.
It can be applied to a static or instance method. If it's an instance method, the class must have a default constructor and it will be created with a lifespan of the entire test run. This is also by design.
现在这还不是很漂亮,但是它应该可以实现相同的功能,也许他会在3.0中使它变得更加整洁。 :)
关于unit-testing - NUnit是否支持组装拆解的概念?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14288454/