NSPec - The evolution of unit tests into behavior description? - ISerializable - Roy Osherove's Blog

NSPec - The evolution of unit tests into behavior description?

Get ready for another naming storm. This time it's going to be "Behavior Driven Development". The most important thing coming out of the BDD "movement" thee days is NSpec - a framework and specification for writing Behavior Verification code (Think Unit Tests with a clearer syntax that explains what you're *really* doing).

Here's a code sample using NSpec:

 

 

              [Specification]
                public void BooleanSpecificationExample()
                {
                        // ...Some set up code...
                        Specify.That( someObj.SomeMethod() ).ShouldBeFalse();
                        // Or...
                        Specify.That( someObj.SomeOtherMethod() ).ShouldBeTrue();
                }

 

Does feels pretty nice, but I think there's along way to go before this start feeling like something I would use for my production code. Still, I think this is an interesting direction to go, but the real development would be to make these behaviors possibly written by the customer for specific scenarios, and the developer for other scenarios - one system that handles both cases.

Not that the customer should write code, but they can write in a laungage that can be transformed into such code. With this syntax it's possible.

Still - this is a long way away, and right now, NSPec looks awful promising.

 

[via larkware]

 

 

Published Wednesday, June 28, 2006 5:00 PM by RoyOsherove
Filed under:

Comments

Wednesday, June 28, 2006 11:12 AM by Adam Vandenberg

# re: NSPec - The evolution of unit tests into behavior description?

I'm trying to see how this is more than just "Asserts by any other name."

I'm all for clear syntax, but:
Specify.That( someObj.SomeMethod() ).ShouldBeFalse();
vs:
Assert.IsFalse( someObj.SomeMethod() );

feels like verbosity for the sake of verbosity.

It doesn't feel like I'm defining a "specification" especially since I'm actually calling "someObj.SomeMethod". I'm not defining rules or constraints, or doing anything clever with relfection, I'm just asserting with more characters.
Wednesday, June 28, 2006 1:16 PM by Joe

# re: NSPec - The evolution of unit tests into behavior description?

I agree with Vandenberg, much too low level.
Wednesday, June 28, 2006 3:52 PM by Kevin D. White

# re: NSPec - The evolution of unit tests into behavior description?

I agree. Specifications are generally considered to be at higher level than unit testing. I would also argue that since clients don't write unit tests, the won't be writing code behaviors either. It's too low level.
Wednesday, June 28, 2006 3:54 PM by Raul

# re: NSPec - The evolution of unit tests into behavior description?

Oh I get it.....it's unit tests written in VB ;-)
Wednesday, June 28, 2006 5:36 PM by Special-K from M is MF

# re: NSPec - The evolution of unit tests into behavior description?

Probably I'm missing something, but I think BDD has been invented a long time ago, and its name was "Cobol"
Wednesday, June 28, 2006 11:24 PM by Bil Simser

# re: NSPec - The evolution of unit tests into behavior description?

I'll throw my hat in the "me too" ring. I thought it was interesting at first, but really it's just a verbose way of doing asserts. Is it more readable? Maybe to someone who doesn't code, but is that really worth it since the audience who codes should know how to read code and not a book. Having said that, I think there's a place for BDD or SDD (specification driven development, but sounds like a venerial disease doesn't it?) and I can see some growth towards that, but not here.
Thursday, June 29, 2006 5:43 AM by Jb Evain

# re: NSPec - The evolution of unit tests into behavior description?

Also, you can have a look to Specter, specter.sf.net, which is an other BDD framework, but uses the nice Boo language features. Worth a look.
Thursday, June 29, 2006 11:35 AM by AndrewSeven

# re: NSPec - The evolution of unit tests into behavior description?

This sounds a bit like how Eiffel works, however, as was said, this is example is just Asserts with a different class name.

COBOL, lol.

I think I get it: "English-like sin tax"

Thursday, June 29, 2006 11:49 AM by AndrewSeven

# re: NSPec - The evolution of unit tests into behavior description?

A quick look at the site shows that they seem to want a new name for TDD rather than a new game. ;)

Monday, July 03, 2006 1:31 PM by ybs

# re: NSPec - The evolution of unit tests into behavior description?

Isn't that something like Spec#? See here: http://research.microsoft.com/specsharp/