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. Java笔记:有啥记啥

    构造方法可以初始化,也可以在调用的时候传参 1android需要java什么水平 2java封装

  2. cglib动态新增类方法

    <dependency> <groupId>cglib</groupId> <artifactId>cglib</artifactId> & ...

  3. iOS 之UIButton左文右图

    对于button,当添加了图片时,默认是左图右文的 '[self.pageViewsLB setImage:[UIImage imageNamed:@"read"] forStat ...

  4. 利用yeoman快速搭建React+webpack+es6脚手架

    自从前后端开始分离之后,前端项目工程化也显得越来越重要了,之前写过一篇搭建基于Angular+Requirejs+Grunt的前端项目教程,有兴趣的可以点这里去看 但是有些项目可以使用这种方式,但有些 ...

  5. php 批量删除

    <body><form action="shanchu.php" method="post"><table width=" ...

  6. 同一行多个div宽度自适应布局

    主要运用到的是:布局神器display:table-cell 元素两端对齐 第一个案例是让两个元素分别向左和向右对齐,如果是过去,我一定会用float来实现,但其实用table可以这么做: 自动平均划 ...

  7. 查看openssl的版本

    [root@ha01 tengine]# openssl version -a OpenSSL Feb built on: Thu Jul :: UTC platform: linux-x86_64 ...

  8. 鱼搜_鱼搜官网_鱼搜搜索_http://www.7yusou.com

    收集了N多视频小站,然后花了3天时间弄了一个鱼搜搜索网站.欢迎大家访问哟. http://www.7yusou.com

  9. css雪碧图生成工具4.1更新

    V4.0介绍地址:http://www.cnblogs.com/wang4517/p/4493917.html 此次更新主要针对已有BUG的修复,用户可在客户端上直接看到更新信息,自己去下载 已修复问 ...

  10. HEAP CORRUPTION DETECTED :after Normal block 错误

    http://blog.csdn.net/zhccl/article/details/7889590