SpecUnit - make your tests more readable
Thought I'd start the year of by sharing this good little add-on for unit testing that I came across recently.
If you are unit testing with NUnit in .NET 3.5 - this may be of interest to you. Its an add-on called 'SpecUnit' which basically enables you to write your tests with a more fluent interface - so that your tests read more like english, and less like robots.
You can download SpecUnit here: http://code.google.com/p/specunit-net/
When you want to use it you just need to add a reference to the SpecUnit.dll, and import the 'SpecUnit' namespace ( using SpecUnit; )
Here is an example of a test I just wrote with it (with setup details omitted for readability):
[TestFixture]
public class When_the_report_transfer_completely_fails
{
[Test]
public void An_email_alert_should_be_sent_out()
{
_EmailGateway.SentEmails.Count.ShouldEqual(1);
//Previously: Assert.AreEqual(1, _EmailGateway.SentEmails.Count)
}
[Test]
public void The_recipient_should_be_the_configured_alert_email_address()
{
var alert = _EmailGateway.SentEmails[0];
alert.To.ShouldEqual("Testing@Test.com");
//Previously: Assert.AreEqual("Testing@Test.com", alert.To)
}
}
As you can see the extension methods (ShouldEqual, ShouldBeNull etc) make the Assertion read like a real sentence. (or at least closer than previously using the Assert.AreEqual(...)
If your wondering how the string or int class has the methods 'ShouldEqual' etc all of a sudden - read up on Extension Methods for .NET 3.5
At first this may seem quite small, but its a step in the right direction of making your tests readable so that they document and describe the intended use of the code in a way readable to humans.
I like it.






At first this may seem quite small, but its a step in the right direction of making your tests readable so that they document and describe the intended use of the code in a way readable to humans .
I like it.
Reply to this
crystal has an antireflective coating and the chronograph hands are in a distinctive yellow colorThe case back carries the legend 49er class and the watch is presented in a special presentation box that contains a message of gratitude from the International 49er Class AssociationThe 2010 CollectionIn addition to the 49er Class Chronograph the 2010 collection includes two other chronographs on steel bracelets and a Kinetic Direct Drive model whose black strap and black hardcoating case create a distinctive and unique appearance to match the cartier declaration replica rolex unique Kinetic Direct Drive technology within replica watches Seiko Velatura 2010 Specifications Alarm ChronographCaliber 7T62Case replica hermes watches Stainless steel with black hard coatingBand Polyurethane strap with stainless steel clasp SNAE17 Stainless steel with threefold clasp with push button release SNAE21CaseStainless steel with blue hard coatingBandStainless steel with threefold clasp fake breitling watches
Reply to this
From Russia With Love 1964 years a lange sohne watches Goldfinger Goldfinger and 1965's Thunderball Thunderball or even 1969's " Queen's emissary "On Her Majesty's Secret Service in one with the Original Rolex Oyster Pepetual different 007 are also wearing the Submariner In 1995 Pierce Brosnan as the new term film actor in "Golden Eye GoldenEye" one fake cartier watches the Omega Omega Rolex sponsored new movie budgets away business handsome Pound is also equipped with updated replaced Omega Seamaster Professional Since then breitling replica the one hand people's memories are always short-lived one is watch factory a strong relationship between marketing Omega Seamaster has replaced the replica Rolex Submariner this into the minds of ordinary people Pound watch And co-ordinated in 2002 can rival the "Die Another Day" performed listed Omega has also introduced a special limited edition Seamaster James Bond tudor fake In any case tag heuer Rolex in 1968 re-launch of the first team
Reply to this
technology Not having to change the battery has many advantages over a traditional quartz watch and also means that the case back does not have to be removed It is definitely a wonderful watch to wear For men the Solar-Tech 180 Titanium is a rugged looking sport watch that is water resistant up to 200 metres It is a quartz watch with a one-way rotation elapsed-bezel replica watches date window and a screwed down crown It is a very light and durable watch replica omega watches being mostly titanium and has a good safety clasp A Chrono-Time AT is a very high tech watch with atomic timekeeping with radio controlled accuracy It gives the time in 26 cites replica vacheron constantin patrimony watches a 15 second chronograph measuring up to 60 minutes alarm perpetual calendar and much more It is all stainless steel water resistant up to 200 metres and also never needs a battery With the black dial and red highlights watches this is the watch of a lifetime the Largo has a dressier look all stainless steel and black dial with the same water resistant and battery features as all Citizen Eco-Drive watches replica patek philippe complications watches It
Reply to this
At first this may seem quite small, but its a step in the right direction of making your tests readable so that they document and describe the intended use of the code in a way readable to humans .
Reply to this
this code doesn't seems to be working as we had tried this step and can you guide me how to download the specunit?i cant find out there
Reply to this
Nice blog.Keep it up!
Reply to this
Resources like the one you mentioned here will be very useful to me! I will post a link to this page on my blog. I am sure my visitors will find that very useful.
Reply to this
An excellent presentation. Clear. Practical. Insightful. Shows a depth of experience. Thank you. I learned a great deal.
Reply to this
over 40,000 cartier bracelets consumers around the world."
Reply to this
Buy Chanel handbags online, best Chanel bags on sale! Chanel Wallets for sale Chanel Purses onlie 马文鑫测试
Reply to this