Devlico.Us
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @devlicious

Casey Charlton - Insane World

Hang the code, and hang the rules. They're more like guidelines anyway


Finally a Good Use for Extension Methods - Unit Testing

I somehow missed this post by Ben a few weeks back, but it is a great example of extension methods making something much clearer than it was before - by putting common Asserts into a few extension methods.

Leveraging simple extension methods to make your tests more concise and readable can really help reduce the overall weight of your tests (especially if you want to change behavior later).  This stands as an excellent reminder to write high-quality test code, just as you would for production code.

I'm generally a big sceptic of extension methods, so far every one I have used (or been forced to use by ASP.NET MVC) has been a little dubious and has proved a pain to track problems down to - but in a unit test suite, at least with the examples Ben gives, these can be a real boon to clarity and consistency.

 


Published Oct 02 2008, 08:01 AM by Casey Charlton
Filed under: ,

About Casey Charlton

A somewhat passionate and opinionated developer, with occassional sparks of wisdom, and occasional useful information. Check out Devlicio.us!

Our Sponsors

Red-Gate!