unit-testing - NUnit是否支持组装拆解的概念?

标签 unit-testing nunit resource-cleanup

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:

  1. The name makes it a little unobvious in this usage.

  2. NUnit allows any number of these and calls them all, without any guarantee of ordering. This is by design.

  3. 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/

相关文章:

c# - 在 headless 单元测试中运行时,如何使 WebBrowser 完成导航?

c# - 在单元测试的开关案例中的特定情况下,如何仅调用一个函数?

python - 无论如何,在退出时关闭sqlite3数据库

php - 如何解决 PHP 中缺少 finally block 的问题?

unit-testing - 如何用reflect测试方法?

unit-testing - 为什么我的单元测试需要一个模拟框架?

python - 如果引发异常,测试会失败吗?

c# - 如何确定哪个是 SUT,哪个是单元测试的合作者?

c# - 为什么在 TeamCity 中运行测试比直接在 NUnit 中运行测试花费的时间更长?

java - java Play! 返回结果后如何执行代码框架?