On October 23rd, 2014, we updated our
By continuing to use LinkedIn’s SlideShare service, you agree to the revised terms, so please take a few minutes to review them.
Share Point Development With Unit TestingPresentation Transcript
SharePoint Development with Unit Testing JEREMY THAKE
OBJECTIVES To explain the 3 goals of unit testing To explain where you can unit test To describe the 3 approaches to unit testing in SharePoint
Unit Testing Run quickly Run on every developer machine Minimal no config (We are not testing MS code)
Where to test? ASP.NET Web Forms Application Pages Web Parts Event Receivers Feature Receivers Workflow coding activities Timer Jobs
WHAT ITS NOT!
UNIT TEST 101 SETUP
TIGHTLY COUPLED CODE
SharePoint + Mocking Interfaces are rarely used Sealed classes Internal Constructors TypeMockIsolator for SharePoint
WRAPPERS & façades
MVP – Model View Presenter
What to test? TDD - lots of code when 80% is usually SharePoint code Tests functionality and requirements work Can cover scenarios and edge cases Missing or empty URL variable Valid URL variable syntax Existence of the specified site Missing or empty ListName variable Existence of the specified list Valid SPListItemCollection return object Null or empty SPListItemCollection return object
MOCKING LARGE AREAS OF SHAREPOINT
CONCLUSION It not easy “Lots of code” Benefits when refactoring other developers changing it environment dependencies reduced speed Doesn't stop poor quality code: list.Items.Count Dispose()