单元测试框架 - 有哪些主要特点主要特点、框架、单元测试、有哪些

2023-09-03 06:43:07 作者:谁动了我的心弦

我已经读了很多有关可用的.NET单元测试框架。什么是我不明白什么是区分现有框架的主要功能。什么是必须具备的,你看评估的单元测试框架时的特点是什么?

I've read a lot about the available .NET unit testing frameworks. What is not clear to me is what are the key features that differentiate the available frameworks. What are the must-have features that you look for when evaluating unit testing frameworks?

推荐答案

我同意,他们都非常相似,当涉及到的断言等基本功能。当他们开始不同的是在更高级的选项,如脚本框架,构建工具,自动化的集成等。

I agree that they are all quite similar when it comes to assertions and other basic features. Where they begin to differ is in more advanced options, such as scripting frameworks, build tools, automated integration, etc.

如果您打算运行使用类似CruiseControl.NET了大量的自定义生成选项和自定义scritpting我可能会使用NUnit的一个高度自动化的构建过程。有很多基于测试结果触发其他操作的更多的钩子。

If you intend to run a highly automated build process using something like CruiseControl.NET with a lot of custom build options and custom scritpting I would probably use NUnit. There are a lot more hooks for triggering other actions based on the test results.

如果你是刚开始使用单元测试,只打算做基本的集成测试,我将与MSTest的坚持,因为它与Visual Studio的紧密集成,2008年(NUnit的有选择的IDE整合,但更好的工具,费钱。)

If you are just getting started with unit testing and only plan on doing basic integration testing I would stick with MStest because of its tight integration with Visual Studio 2008. (NUnit has options for integrating with the IDE but the better tools cost money.)

下面是一个小对比表:

          | 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
---------------------------------------------------------------------------------