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.
Posted
10-02-2008 8:01 AM
by
Jak Charlton