Approach to Testing
Shweet's primary goal is to provide good examples of how to unit test SharePoint projects using Pex, Moles and Behaviours. To help with this we adopted different unit testing techniques across the project to help guide people towards the more complex scenarios.
Testing with Moles
Sometimes, as is the case with SharePoint, it is not possible to test using Dependency Injection. In this scenario we need to isolate the code using a framework.
Tests with Moles
Testing with Behaviours
An Isolation approach to testing, although valid, tends to introduce too much of the internal workings from the code under test into the unit tests. This leads to brittle tests where a small change to the production code results in false test failures. Using
Behaviours the objective is to hide the isolation complexity away from the tests but also make the tests less brittle.
Tests with Behaviours
Testing with Pex
Pex testing is all about finding things in your code that you didn't know existed or should be tested. The challenge doing Pex is how to paramterize your tests and how you can assert that the test did what you expected based on these parameters.
Using Pex to automate the white box testing