I have a more involved blog post on this on the TODO list, but have promised a few folks some links to resources on how to unit test CRM/xRM code you write.  If you Bing (or that other search engine) “Unit Test” and “CRM 2011” you will come up with some good ideas that cover different .NET coding scenarios.  An approach I am a fan of is using Pex and Moles.  Until I have to to blog a walkthrough or screencast on it, those willing to do the mental translation can use the Unit Testing SharePoint Foundation with Pex and Moles whitepaper.  If you read it, you should be able to figure out how you would use the same approach with CRM code.  For JavaScript unit testing, take a look at QUnit which has fast become one of the more popular testing frameworks for JavaScript.

@devkeydet