Clean Code and Unit Testing

I am studying hard for my 70-568 exam at the end of the month so I have not dived deeper into development.  I did read Martin’s Clean Code over the last week and I found myself nodding in agreement more often than not.   I’ll never look at code comments the same way again.

 

I also started The Art of Unit Testing by Osherove.  I assumed that there were different levels of Unit Testing – good enough, good, and great.  However, Osherove doesn’t define it like that – he maintains that Unit Testing is a progression to Stubbing and Mocking.  If so, you need to refactor all of your code to include Interfaces and Dependency Injection and then use a Mocking Framework.  In short, there is no way to Unit Test an existing project that wasn’t set up for Testing in the 1st place. 

 

I think this is where dogma meets progma (my word, use it at your peril)  – I know many projects that would benefit from basic testing (Unit, Regression, Integration or a combo/bastardization of all three) but to refactor the code to support IoC and Mocking is not viable.  I know that Unit Testing is still in its infancy so I wonder if additional patterns will develop to support testing that defies traditional definitions.

Advertisements

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: