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.本篇作为入门,介绍了单元测试的基础知识,例如:如何使 ...
随机推荐
- JavaCV配置
下载javacv-1.2-bin.zip https://github.com/bytedeco/javacv 解压 在Eclipse项目 Referenced Libraries 中 Add Ext ...
- 如何在eclipse中通过Juit进行单元测试
1.什么是Junit Junit即单元测试,是JAVA语言的单元测试框架,是对程序的一个方法所进行的测试 一般都是由程序员自己通过Junit来进行测试,因此单元测试也叫程序员测试: 如果测试人员熟悉程 ...
- android 实现返回键执行home键方法
在公司的产品开发,中老板很是执着于,不要看到启动界面,但是又不想去掉启动界面. so 实现返回键执行home键方法. public boolean onKeyDown(int keyCode, Key ...
- Python爬虫进阶二之PySpider框架安装配置
关于 首先,在此附上项目的地址,以及官方文档 PySpider 官方文档 安装 1. pip 首先确保你已经安装了pip,若没有安装,请参照 pip安装 2. phantomjs PhantomJS ...
- Hadoop单机模式安装-(2)安装Ubuntu虚拟机
网络上关于如何单机模式安装Hadoop的文章很多,按照其步骤走下来多数都失败,按照其操作弯路走过了不少但终究还是把问题都解决了,所以顺便自己详细记录下完整的安装过程. 此篇主要介绍在虚拟机设置完毕后, ...
- react-native 踩坑记
最近在使用react-native的时候遇到了很多坑,这里给大家分享下 一.样式 react-native 虽然支持flex布局,但是所有的样式均是css样式的一个很小的集合,尤其是在安卓机下问题尤为 ...
- Python-Hello world!
一.Python安装 Windows 1.下载安装包 https://www.python.org/downloads/ 2.安装 默认安装路径:C:\python3.5 3.配置环境变量: [右键计 ...
- Jetpack 由 WordPress.com 出品
官网:https://jetpack.com/ Jetpack 由 WordPress.com 出品. Jetpack 通过为您提供访客统计数据和安全服务.加速图像传输以及帮您获得更多浏览量,可以简化 ...
- React-webpack开发需要的那些坑
nvariant Violation: _registerComponent(...): Target container is not a DOM element. 就是一个找不到DOM节点的问题, ...
- CentOS 6.4下编译安装MySQL 5.6.14
概述: CentOS 6.4下通过yum安装的MySQL是5.1版的,比较老,所以就想通过源代码安装高版本的5.6.14. 正文: 一:卸载旧版本 使用下面的命令检查是否安装有MySQL Server ...