Update 8/3/2009: I updated some statements to avoid misunderstandings ...
As the kind of solutions we built on SharePoint become increasingly more complex it might be an interesting idea to take a look at creating unit tests for your solutions (although some people might tell you that it is not always worth the effort - see Peter Seale - SharePoint: not unit testing ). There are some challenges when trying to create unit tests for SharePoint development as outlined in Unit Testing SharePoint 2007 Applications. An interesting approach is using Isolator for SharePoint which allows unit testing sharepoint code without needing SharePoint installed (You would typically run your unit tests on your build server so this is quite handy). If you look at the SharePoint Guidance of the Patterns&Practices group you will notice that they are using the same approach.
A good resource to get you started is the great series of whitepapers about unit testing and SharePoint written by Andrew Woodward:
- Unit Testing SharePoint Solutions - The basics (White paper - Andrew Woodward) and the codesamples which go along
- Unit Testing SharePoint Solutions - Getting into the object model (White paper - Andrew Woodward) and the codesamples which go along
Related resources:
- Shared Points for SharePoint - Unit testing SharePoint code
- Shared Points for SharePoint - Unit testing MOSS part 1 (of 2)
- Shared Points for SharePoint - Unit testing MOSS part 2 (of 2)
- SPTDD: SharePoint and Test Driven Development Part One
- More thoughts on Test Driven Development with SharePoint 2007
The SharePointDevWIki.com also has coverage on Unit Testing in SharePoint.
ReplyDeleteCurrently it covers an overview of how to configure an existing project with unit testing.
Shortly I'll be adding some extra bits on scenarios where it makes sense to unit test and those that it doesn't as I think there's a lot of confusion on that.
Check out it out here http://sharepointdevwiki.com/display/public/SharePoint+Development+with+Unit+Testing.
Another place with good resources for unit testing SharePoint is http://www.typemock.com/sharepointpage.php
ReplyDelete