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的更多相关文章

  1. MSTest、NUnit、xUnit.net 属性和断言对照表

    MSTest.NUnit.xUnit.net 属性对照表 MSTest NUnit xUnit.net Comments [TestMethod] [Test] [Fact] Marks a test ...

  2. (转)对比MS Test与NUnit Test框架

    前言: 项目中进行Unit Test时,肯定会用到框架,因为这样能够更快捷.方便的进行测试. .Net环境下的测试框架非常多,在这里只是对MS Test和NUnit Test进行一下比较, 因为这两个 ...

  3. 对比MS Test与NUnit Test框架

    前言: 项目中进行Unit Test时,肯定会用到框架,因为这样能够更快捷.方便的进行测试. .Net环境下的测试框架非常多,在这里只是对MS Test和NUnit Test进行一下比较, 因为这两个 ...

  4. VS2015+NUnit+OpenCover 完成单元测试代码覆盖率测试

    1.VS2015+NUnit+OpenCover 完成单元测试代码覆盖率测试 https://download.csdn.net/download/qq_39441918/10522539 2.*注意 ...

  5. dotnet core test with NUnit

    https://github.com/nunit/dotnet-test-nunit if you are using Visual Studio. Your project.json in your ...

  6. Xunit

    Attributes Note: This table was written back when xUnit.net 1.0 has shipped, and needs to be updated ...

  7. xUnit随笔

    XUnit入门 1.如果之前安装了xUnit.net Visual Studio Runner扩展包,通过"工具"菜单下的"扩展和更新"先将该扩展包卸载. 2. ...

  8. .NET Core Ecosystem

    .NET .NET Blog Application Models Web Mobile Desktop Microservices Gaming Machine Learning Cloud Int ...

  9. .NET单元测试的艺术-1.入门

    开篇:最近在看Roy Osherove的<单元测试的艺术>一书,颇有收获.因此,将其记录下来,并分为四个部分分享成文,与各位Share.本篇作为入门,介绍了单元测试的基础知识,例如:如何使 ...

随机推荐

  1. express中的路由

    一.读取静态文件 基本代码: "use strict"; const express = require("express"); let app = expre ...

  2. SSM框架总结(1)

    ----------------------20170106-------------------------------------- 1.mabatis.genertor中自动生成文件,需要在ge ...

  3. Css格式与布局

    一.位置 1.绝对定位 position:absolute:绝对定位. 绝对位置的意思就是相对于浏览器边框的位置,回归到它应有的位置.也就是说,一个div使用绝对定位后是在浏览器边框的最左上角位置.而 ...

  4. 五星评分效果 原生js

    五星评分在很多地方都可以用到,网上也有插件或者相应的代码,在这里我给大家提供一款我自己写的超级简单实用的五星评分代码,连图片都不需要 <!-- 评分start --> <ul> ...

  5. Lintcode 150.买卖股票的最佳时机 II

    ------------------------------------------------------------ 卧槽竟然连题意都没看懂,百度了才明白题目在说啥....我好方啊....o(╯□ ...

  6. div不换行_div同行_div强制不换行

    使用Float <!--已知两个div的宽度使用[Float]使两个DIV同行!注:float使用后需要清除:所以多写一个div--> <div style="width: ...

  7. Python 判断字符串是否为数字

    转载: http://www.runoob.com/python3/python3-check-is-number.html 以下实例通过创建自定义函数 is_number() 方法来判断字符串是否为 ...

  8. Oracle连接与会话

    连接(connection):连接是从客户端到oracle数据库实例的一条物理路径. 会话(session):会话是数据库实例中存在的一个逻辑实体. case1:一个连接可以有多个会话 SQL> ...

  9. Future和Promise

    Future用于获取异步操作的结果,而Promise则比较抽象,无法直接猜测出其功能. Future Future最早来源于JDK的java.util.concurrent.Future,它用于代表异 ...

  10. Daily Scrum Meeting ——FourthDay(Beta)12.12

    一.Daily Scrum Meeting照片 讨论界面优化详情 二.Burndown Chart 项目有条不紊地进行中... 1.新增6个界面修改计划 2.修复两个BUG 三.项目进展(check- ...