"unit testing is a method of testing that verifies the individual units of source code are working properly. A unit is the smallest testable part of an application. In procedural programming a unit may be an individual program, function, procedure, etc., while in object-oriented programming, the smallest unit is a method, which may belong to a base/super class, abstract class or derived/child class"
Wikipedia - Unit Testing
In SharePoint Development, Unit Tests are hard to build due to the large number of dependencies on SharePoint Development in general.
There are multiple approaches to introducing Unit Testing into SharePoint Development:
Pros and Cons of Unit Testing in SharePoint Development
| Encourages TDD development
|| Lots of plumbing - More code and complex project structures
| You know when something breaks in an intricate system
|| Negative and Positive - how far to go with this is hard to define e.g tests for invalid urls
| Communicates funcionality in team development
|| People only test code they know works
|| People tend to use it as integration test rather than discrete unit tests
Getting Started with SharePoint Unit Testing
What can be tested?
SharePoint Development with Unit Testing webcast
View in Browser
The SharePoint community has currently moved toward Test Driven Development but below are some useful links regarding Unit Testing in general.
sporm is a CodePlex project that has appeared in Alpha as of Aug 09. It takes the approach of building an ORM across a site collection which you consume rather than the API directly.
Traditionally SharePoint projects are hard to unit test, use weak typing, and require complicated XML to query for data. Sporm (TM) is specifically designed to simplify unit testing, enable strongly typed objects, and support LINQ access to SharePoint objects.
- Simplifies unit testing - by hiding unmockable objects like SPWeb and SPListItem
- Enables strongly typed code - by generating classes and properties for lists and content types
- Eliminates the need for ugly loosly typed CAML queries - by acting as a LINQ provider to your lists