单元测试框架 - 主要功能有哪些

Jas*_*win 8 .net frameworks unit-testing

我已经阅读了很多关于可用的.NET单元测试框架的内容.我不清楚的是,区分可用框架的关键特性是什么.在评估单元测试框架时,您需要具备哪些必备功能?

jel*_*key 1

我同意它们在断言和其他基本特征方面都非常相似。它们的不同之处在于更高级的选项,例如脚本框架、构建工具、自动化集成等。

如果您打算使用 CruiseControl.NET 等具有大量自定义构建选项和自定义脚本的工具来运行高度自动化的构建过程,我可能会使用 NUnit。还有更多的钩子可以根据测试结果触发其他操作。

如果您刚刚开始进行单元测试并且只计划进行基本的集成测试,我会坚持使用 MStest,因为它与 Visual Studio 2008 紧密集成。(NUnit 有与 IDE 集成的选项,但更好的工具需要花钱。)

这是一个小比较表:

          | NUnit                            | MStest
---------------------------------------------------------------------------------
Asserts   | missing some collection asserts  | missing some numeric/date asserts
---------------------------------------------------------------------------------
Speed     | test run fast, faster setup on   | w/ VS 2008 no setup necessary on
          | servers and the like             | the client, test run fairly fast.
---------------------------------------------------------------------------------
Options   | a lot of 3rd party add-ons and   | some 3rd party tools
          | other tools                      |
---------------------------------------------------------------------------------
CC.NET    | good integration, lots of tools  | newer versions of CC.NET support
          | and options                      | MS test out of the box, not as
          |                                  | many add on tools
---------------------------------------------------------------------------------
Run Code Online (Sandbox Code Playgroud)