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.本篇作为入门,介绍了单元测试的基础知识,例如:如何使 ...
随机推荐
- linux部署pxe+kickstart批量安装linux操作系统
环境 系统 centos6.6 无图形界面 ip 192.168.2.1 系统 centos7.2 有图形界面 以下命令在centos6.6上执行 1. yum -y install dhcp* tf ...
- 如何在Eclipse下查看JDK源代码
在Eclipse中查看JDK类库的源代码!!! 设置: 1.点 "window"-> "Preferences" -> "Java&quo ...
- 【Java EE 学习 75 下】【数据采集系统第七天】【二进制运算实现权限管理】【使用反射初始化权限表】【权限捕获拦截器动态添加权限】
一.使用反射动态添加权限 在该系统中,我使用struts2的时候非常规范,访问的Action的形式都是"ActionClassName_MethodName.action?参数列表" ...
- 读书笔记《深度探索c++对象模型》 概述
<深度探索c++对象模型>这本书是我工作一段时间后想更深入了解C++的底层实现知识,如内存布局.模型.内存大小.继承.虚函数表等而阅读的:此外在很多面试或者工作中,对底层的知识的足够了解也 ...
- CSS系列:在HTML中引入CSS的方法
HTML与CSS是两个作用不同的语言,它们同时对一个网页产生作用,因此必须将CSS与HTML链接在一起使用.在HTML中,引入CSS的方法主要有4种:行内式.内嵌式.导入式和链接式. 1. 行内式 行 ...
- Addthis
WordPress外贸主题模版可以非常方便地整合国外流行的分享收藏社会化网络功能,比如Addthis是国外一个网络书签按钮聚合网站,是稳步提升网站流量和搜索引擎排名的WEB2.0工具!通过AddThi ...
- 毕业论文—使用js将canvas保存为图片文件,并且自定义文件名
该文章引用http://blog.csdn.net/qq547276542/article/details/51906741 1.从canvas中直接提取图片元数据 // 图片导出为 png 格式 v ...
- 关于安装Apache之后,解析PHP的配置
需要配置四个地方 LoadModule php5_module modules/libphp5.soServerName localhost:80DirectoryIndex index.phpAdd ...
- my97DatePicker选择年、季度、月、周、日
My97DatePicker是一款非常灵活好用的日期控件.使用非常简单. 下面总结下使用该日历控件选择年.季度.月.周.日的方法. .选择年 <input id="d1212" ...
- Codeforces 624
B. Making a String time limit per test 1 second memory limit per test 256 megabytes input standard i ...