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.本篇作为入门,介绍了单元测试的基础知识,例如:如何使 ...
随机推荐
- SQL多表查询,消除表中的重复的内容
看到朋友再写一个SQL语句:两个表a1表中有SN.SN2.TN,b1表有SM.SM2.TN2,若a1的SN中的数据和b1的SM中的数据是一致的,那么将a1中对应的数据修改成b1中对应的数据. upda ...
- vue2.0 组件之间的数据传递
组件间的数据传递// 父组件<template><div class="order"><dialog-addpro v-on:closedialog= ...
- js,jq,css选择器
js获取节点: var chils= s.childNodes; //得到s的全部子节点 var par=s.parentNode; //得到s的父节点 var ns=s.nextSbiling; / ...
- 转:大神提出来的java服务器方面面试问题(当作自己的学习目标平时得多注意)
因为一些个人原因,陆陆续续参加了一些校招补招.社招的笔试和面试(BAT),也包括一些国外公司(Spotify, Google, Ericsson),最后有幸被网易收入麾下,拿到了S.下面罗列一些我复习 ...
- 【leetcode】Pascal's Triangle
题目简述: Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5 ...
- android中 onResume()方法什么时候执行 ??(转)
转自: onResume是在启动activity启动之后才能执行的,也就是恢复执行.程序正常启动:onCreate()->onStart()->onResume();正常退出:onPaus ...
- SQL常见优化Sql查询性能的方法有哪些?
常见优化Sql查询性能的方法有哪些? 1.查询条件减少使用函数,避免全表扫描 2.减少不必要的表连接 3.有些数据操作的业务逻辑可以放到应用层进行实现 4.可以使用with as 5.使用“临时表”暂 ...
- android-sdk 开发连接不上
74.125.237.1 dl-ssl.google.com
- solr update接口常用方法
solr索引数据更新接口:http://localhost:8080/solr/update 有以下一些操作可以通过update接口完成,只能使用post的形式提交数据. 1.添加索引 确保field ...
- http tcp udp ip 间的关系
首先,我自己梳理一下,其实除了应对以后的笔试,还有需要应对的是自己在编程中对于api的选择,我在满足需求时采取哪种方案更好. 首先,我需要了解的是tcp/ip是一个协议组,有三大层: ip 对应于网络 ...