NBehave alpha now shipping with Should assertion framework

 

It recently came to my attention (when dog-fooding the new version), that I wasn’t able to make any assertions!

Using NBehave without a unit testing framework means we need some other way of checking our results. So I’ve included the Should framework to complete the testing story.

I’m finding it quite a nice framework to use, and its very feature complete. I’ve ILMerged it into the main NBehave.Narrator.Framework assembly, so you don’t need to pull in any references!

Personally I prefer the Fluent API which is quite friendly to intelli-sense, and readability. Here’s an example for a test I’m writing now:

[Then("I should get the available sessions")]
public void ThenIShouldGetTheAvailableSessions()
{
    sessions.Count().Should().Be.GreaterThan(0);
}

You can grab the new version here.

October 29 2010

Comments (1) -

Lazydev

You have been able to do Asserts in NBehave for a long time, check the extension methods in the nbehave.specs.nunit namespace Smile
The bad part is that this ties you to a specific version of nunit (or mstest, mbunit depending on which you use).
We have been talking about switching out those in favour of Should, but I would like to check which asserts Should dont have thats in nbehave before we switch. We have used the existing extension methods in nbehave quite heavily for ~2 years at the project at work so I would prefer if most assertions we have also exist in Should Smile

Lazydev | 10/29/2010 1:36:40 PM |

Comments are closed