NUnit Extension小介绍

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


Extension类型

 

Add In

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

 

Add On

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

 

Runners

提供另外一种方式运行NUnit

 

Extras

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

 

Available Extensions

 

 Extension Description Type Author
CSUnit Addin Runs csUnit tests under NUnit without recompilation. Addin Charlie Poole
Common.Addin.Build Common build script for use in building NUnit addins. Addin Charlie Poole
Extension Methods For Nunit A DSL for constraint specification Addon Jonathan Knezek
FireBenchmarks Performance testing addin for NUnit. Addin Federico Coletto
IterativeTest Data-driven testing alternative. Addin Kelly Anderson
MSBuild-NUnit MSBuild task to run NUnit Runner Rafael Teixeira & Paul Welter
NAnt-task NAnt task to run NUnit Runner Daniel Nauck
Njasmine A DSL for writing tests as Given/When/Then specifications, inspired by Jasmine. Addin Frank Schwieterman
Nunit-Results Produces HTML reports from one or more NUnit test runs. Extra Charlie Poole
Nunit-summary Produces HTML or text reports from one or more NUnit test runs. Extra Charlie Poole
Nunitex NUnit constraint syntax based on extension methods Addon Fabio Maulo, Simone Busoli
ORAYLIS BI.Quality ORAYLIS 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. Addon Thomas Strehlow (ORAYLIS GmbH)
Rowtest Allows writing mbUnit-style RowTests under NUnit Addin Andreas Schlapsi
TestDriven.Net Zero friction unit testing extension for Visual Studio Runner Jamie Cansdale
VisualNunit Open Source NUnit plugin for Visual Studio 2008 and 2010 Runner Tommi S. E. Laukkanen
Watin Test Recorder Tool for use of WatiN with NUnit. Extra Daaron Dwyer, Nick Journals, James Avery
Xtunit Rollback data changes made by a test. Addin Roy 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

 

你可能感兴趣的:(ext)