NUnit Extension小介绍

  NUnit是我们经常使用的测试框架,既然常用,肯定会有人难不住寂寞给TA加上一些自己认为酷的功能上去,也就是扩展,那下面我们就看看到底有几种扩展。


Extension类型

 

Add In

嵌入NUnit内部,改变TA的行为,通常提供一种全新的测试方式,比方说FireBenchmarkers就给NUit加上了性能测试。

 

Add On

在Unit上方或者外部,不像Add In一样修改NUint的行为,通常他们都用来测试一种特殊的应用,或者实现一种新的测试书写风格

 

Runners

提供另外一种方式运行NUnit

 

Extras

除了上面三种之外的,典型的例子是加test report

 

Available Extensions

 

↓ ExtensionDescriptionTypeAuthor
CSUnit AddinRuns csUnit tests under NUnit without recompilation.AddinCharlie Poole
Common.Addin.BuildCommon build script for use in building NUnit addins.AddinCharlie Poole
Extension Methods For NunitA DSL for constraint specificationAddonJonathan Knezek
FireBenchmarksPerformance testing addin for NUnit.AddinFederico Coletto
IterativeTestData-driven testing alternative.AddinKelly Anderson
MSBuild-NUnitMSBuild task to run NUnitRunnerRafael Teixeira & Paul Welter
NAnt-taskNAnt task to run NUnitRunnerDaniel Nauck
NjasmineA DSL for writing tests as Given/When/Then specifications, inspired by Jasmine.AddinFrank Schwieterman
Nunit-ResultsProduces HTML reports from one or more NUnit test runs.ExtraCharlie Poole
Nunit-summaryProduces HTML or text reports from one or more NUnit test runs.ExtraCharlie Poole
NunitexNUnit constraint syntax based on extension methodsAddonFabio Maulo, Simone Busoli
ORAYLIS BI.QualityORAYLIS BI.Quality is a testing suite for BI solutions makes it easier to develop in an agile environment. The suite is based on NUnit and supports quite a lot of different testing methods.AddonThomas Strehlow (ORAYLIS GmbH)
RowtestAllows writing mbUnit-style RowTests under NUnitAddinAndreas Schlapsi
TestDriven.NetZero friction unit testing extension for Visual StudioRunnerJamie Cansdale
VisualNunitOpen Source NUnit plugin for Visual Studio 2008 and 2010RunnerTommi S. E. Laukkanen
Watin Test RecorderTool for use of WatiN with NUnit.ExtraDaaron Dwyer, Nick Journals, James Avery
XtunitRollback data changes made by a test.AddinRoy Osherove

 

  上面的表格中列出了NUnit官方给出的扩展工具,我比较关心的是能让我体面的写出测试的扩展。

 

NUnit Extension Method

 

var actual =2.5;
actual
.Should(Be.EqualTo(2.5).Within(0.5));

  个人感觉不是很好,例子里面层层嵌套,很不习惯,我更倾向于actual.shouldBe(2.5).Within(0.5)

 

Njasmine

  
一种我看不懂的测试写法,作者说是rspec风格,我怎么看着不像。。。从名字上面看,和jasmine有着千丝万缕的联系

 

NUnitex

很强大的一种测试方法扩展,支持NUnit,XUnit,MSTest,这下大家满意了吧。。。

文章作者说:Charlie Poole, NUnit’s project leader, included NUnitEx as official NUnit AddOns “under review for possible inclusion in NUnit 3.0” (thanks Charlie) and we are looking for some response from users (the thread is here).也就是说TA是被NUnit组织推荐的

真实性我就很难验证了。

一些典型的验证方法:

 

actual.Should().Be.True();
actual.Should().Be.EqualTo(something);actual.Should().Be.InstanceOf<SomeClass>();

var
something =newobject();
something.Should()
    .Not.Be.Null()
    .And
  
.Not.Be.EqualTo(newobject());

minvalue
.Should().Be.LessThanOrEqualTo(minvalue +1);
actual.Should().Be.SubsetOf(new[]{1,2,3,4}); 

我认为最牛逼的就是TA居然支持LinQ形式的验证

 

new[]{1,2}.Should().Satisfy(x => x.SequenceEqual(new[]{1,2}));

 

  

这难道不酷么?

 


引用资料:

http://www.nunit.org/wiki/doku.php?id=nunit:extensions

http://code.google.com/p/nunitex/wiki/SyntaxOverview

 

转载于:https://www.cnblogs.com/iammatthew/archive/2012/04/21/2462029.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值