博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Comparing the MSTest and Nunit Frameworks
阅读量:6910 次
发布时间:2019-06-27

本文共 2538 字,大约阅读时间需要 8 分钟。

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  .

转载地址:http://axycl.baihongyu.com/

你可能感兴趣的文章
Git使用++
查看>>
[C++]基本类型转换
查看>>
清除windows系统垃圾文件简易脚本(bat)
查看>>
Android WindowManager实现悬浮窗效果 (一)——与当前Activity绑定
查看>>
陶哲轩实分析 定理7.5.1 (方根判别法) 证明
查看>>
The direct sum of functions
查看>>
《Linux内核设计与实现》读书笔记(十五)- 进程地址空间(kernel 2.6.32.60)
查看>>
python实战===2017年30个惊艳的Python开源项目 (转)
查看>>
TurnipBit:和孩子一起动手DIY“滚动”的生日礼物
查看>>
删除一个链表中的重复元素
查看>>
C# 在多线程环境中,进行安全遍历操作
查看>>
Win7 防护墙设置——Ping命令,Http访问
查看>>
是男人就下100层【第一层】——高仿微信界面(6)
查看>>
day16- re模块(正则表达式 三种查找方法findall search match)
查看>>
CentOS7.x配置bond0
查看>>
vue随记
查看>>
Quick-cocos2d-x3.3 Study (十一)--------- 让物体从屏幕的外边移动到屏幕中指定位置...
查看>>
[转] 数据挖掘中易犯的几大错误
查看>>
select函数用法详解
查看>>
关于Ue4的深度模板
查看>>