Unit tests more complicated than the code?

I spent some time this morning coming up with a nice way for us to test our Linq expression trees against lists when using NHibernate. Who knows, perhaps when I’m a bit less lazy I’ll actually post it here…

I thought it was quite an elegant solution and proceeded to show my colleague, who is currently doing a lot of pair programming with me.

My colleague is a bit new to unit testing, mocking and such and immediately exclaimed that it’s more complicated than the code itself! Well, usually I don’t take it as a compliment if somebody calls something I came up with “complicated”, but in this case I did. The “complicated” code is a once off effort, which makes it easier to do unit tests for our repositories in the future. 

I think it summarises why I like doing TDD, because you can get your hands dirty with some real comiplicated problems which you need to solve. What developer doesn’t like a challenge?

Perhaps my colleague’s reaction explains why a lot of developers don’t fully embrace TDD, because it’s sometime a bit hard and you really need to know your way around the CLR to find a solution.

Advertisements

~ by hendrikswan on March 11, 2010.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: