Comparing the MSTest and Nunit Frameworks
I haven't seen much information online comparing the similarities and differences between the Nunit and MSTest Frameworks. Here I will define the similarities and some of the differences.
MSTest Attribute |
NUnit Attribute |
Purpose |
[TestMethod] |
[Test] |
Indentifies of an individual unit test |
[TestClass] |
[TestFixture] |
Identifies of a group of unit tests, all Tests, and Initializations/Clean Ups must appear after this declaration |
[ClassInitialize] |
[TestFixtureSetUp] |
Identifies a method which should be called a single time prior to executing any test in the Test Class/Test Fixture |
[ClassCleanup] |
[TestFixtureTearDown] |
Identifies a method in to be called a single time following the execution of the last test in a TestClass/TestFixture |
[TestInitialize] |
[SetUp] |
Identifies a method to be executed each time before a TestMethod/Test is executed |
[TestCleanUp] |
[TearDown] |
Identifies a method to be executed each time after a TestMethod/Test has executed |
[AssemblyInitialize] |
N/A |
Identifies a method to be called a single time upon before running any tests in a Test Assembly |
[AssemblyCleanUp] |
N/A |
Identifies a method to be called a single time upon after running all tests in a Test Assembly |
The order of execution is similar in both frameworks, but there are some differences between the two:
- In Nunit, tests are not executed in parallel. Rather, it appears that all tests execute on a single thread. In MSTest, each test is instantiated on a separate thread, this results the runs being interleaved. Therefore, if test A depends on test B for its success, it likely will fail as test B will likely start running as test A is running.
- The time at which ClassCleanUp/TestFixtureTearDown executes is different between the two frameworks. In Nunit, TestFixtureTearDown is executed immediately following the completion of the last test in a TestFixture or after TearDown if the attribute exists for the test in question. In the Whidbey implementation of MsTest, ClassCleanUp executes at the end of a test run, before AssemblyCleanUp but not necessarily immediately after the last test in a TestClass has completed executing.
- In Whidbey, support for test class inheritance was missing. In Nunit, it is fully supported. This will be rectified in Orcas.
I should also mentioned that in MsTest, TestContext exists for passing information about the test run. There is no equivalent in Nunit tests. This can serve as a handy tool for pulling information from datasources on the disk to the unit tests, as well as other uses. More can be read about it here.
Comparing the MSTest and Nunit Frameworks的更多相关文章
- MSTest、NUnit、xUnit.net 属性和断言对照表
MSTest.NUnit.xUnit.net 属性对照表 MSTest NUnit xUnit.net Comments [TestMethod] [Test] [Fact] Marks a test ...
- (转)对比MS Test与NUnit Test框架
前言: 项目中进行Unit Test时,肯定会用到框架,因为这样能够更快捷.方便的进行测试. .Net环境下的测试框架非常多,在这里只是对MS Test和NUnit Test进行一下比较, 因为这两个 ...
- 对比MS Test与NUnit Test框架
前言: 项目中进行Unit Test时,肯定会用到框架,因为这样能够更快捷.方便的进行测试. .Net环境下的测试框架非常多,在这里只是对MS Test和NUnit Test进行一下比较, 因为这两个 ...
- VS2015+NUnit+OpenCover 完成单元测试代码覆盖率测试
1.VS2015+NUnit+OpenCover 完成单元测试代码覆盖率测试 https://download.csdn.net/download/qq_39441918/10522539 2.*注意 ...
- dotnet core test with NUnit
https://github.com/nunit/dotnet-test-nunit if you are using Visual Studio. Your project.json in your ...
- Xunit
Attributes Note: This table was written back when xUnit.net 1.0 has shipped, and needs to be updated ...
- xUnit随笔
XUnit入门 1.如果之前安装了xUnit.net Visual Studio Runner扩展包,通过"工具"菜单下的"扩展和更新"先将该扩展包卸载. 2. ...
- .NET Core Ecosystem
.NET .NET Blog Application Models Web Mobile Desktop Microservices Gaming Machine Learning Cloud Int ...
- .NET单元测试的艺术-1.入门
开篇:最近在看Roy Osherove的<单元测试的艺术>一书,颇有收获.因此,将其记录下来,并分为四个部分分享成文,与各位Share.本篇作为入门,介绍了单元测试的基础知识,例如:如何使 ...
随机推荐
- PLSQLDeveloper 常用设置
PLSQL Developer常用设置及快捷键 1.登录后默认自动选中My Objects (已验证可用) 默认情况下,PLSQL Developer登录后,Brower里会选择All obj ...
- MFC序列化与反序列化
#pragma once #include "afx.h" #include <vector> using std::vector; class HzyData : p ...
- vi编辑器命令
Linux下的文本编辑器有很多种,vi 是最常用的,也是各版本Linux的标配.注意,vi 仅仅是一个文本编辑器,可以给字符着色,可以自动补全,但是不像 Windows 下的 word 有排版功能.v ...
- 上传文件 隐藏input type="file",用text显示
<div> <span>上传文件:</span> <input type="file" id="upload_file" ...
- Linux C编程学习之开发工具3---多文件项目管理、Makefile、一个通用的Makefile
GNU Make简介 大型项目的开发过程中,往往会划分出若干个功能模块,这样可以保证软件的易维护性. 作为项目的组成部分,各个模块不可避免的存在各种联系,如果其中某个模块发生改动,那么其他的模块需要相 ...
- Linux内核--内核数据类型
转自:http://www.linuxidc.com/Linux/2013-12/93637.htm 将Linux 移植到新的体系结构时,开发者遇到的若干问题都与不正确的数据类型有关.坚持使用严格的数 ...
- Unity引擎IOS执行档大小优化
简介 苹果对于IOS执行档的大小是有明确的限制的,其中TEXT段的大小不能超过80M,否则提审将会被苹果拒绝,同时,如果TEXT段过于太大,那么在苹果进行加密之后,很容易出现解压失败等各种异常,最终导 ...
- 21分钟 MySQL 入门教程(转载!!!)
21分钟 MySQL 入门教程 目录 一.MySQL的相关概念介绍 二.Windows下MySQL的配置 配置步骤 MySQL服务的启动.停止与卸载 三.MySQL脚本的基本组成 四.MySQL中的数 ...
- DelphiXE10.1获取Administrator所有权的方法
操作: 菜单选择Proceject->Options->Application->把Enable Admonistrator Privileges打勾(manifest file - ...
- css3clock.js - 一个用CSS3与纯js实现的简单时钟
前言 项目代码明细可以查看我Github上的源码:https://github.com/nelsonkuang/css3clock.js 实现思路 主要是用CSS3控制时针.分针和秒针旋转:时针每12 ...