About Me

Training

Develop With Passion® - Developer Bootcamp

Subscribe

Slight addition to jpboodhoo.bdd

Written February 04, 2009 at 16:00 MST Tagged c sharp

If you recall from the last post on this topic one of the ways you can record an observation is by simply doing this:

[Observation]

public void should_dispose_the_appropriate_items()

{

connection.was_told_to(x => x.Dispose());

}

In addition to be able to define observations using traditional attributes. You can now also define observations by using blocks (like the rest of the code uses). So the following observation is identical to the one above:

it should_dispose_the_appropriate_items = () =>

connection.was_told_to(x => x.Dispose());


Because all of this is backed by MBUnit. You can start integrating this into your existing MbUnit test suites with no change required. MBUnit GUI, and Console pick them up with no problem. TestDriven.Net can even run them. You can mix and match traditional attribute based observations and block style observations in the same test:

it should_leverage_db_infrastructure_to_return_a_set_of_rows_from_the_db = () =>

result.should_not_be_null();

[Observation]

public void should_dispose_the_appropriate_items()

{

connection.was_told_to(x => x.Dispose());

}


The only issue with TD.Net right now, is that you can’t pick a single “it” block to run in a fixture. If you put the cursor on an “it” block and tell TD.Net to run test, it will run all of the “it” blocks in that fixture. If you are using a traditional attribute based Observation block this is not a problem.
If people are interested in how I rolled out this feature, please respond with comments and I will get another post out!!
Develop With Passion!!