Share Point Development With Unit Testing
-
Upload
jeremy-thake -
Category
Technology
-
view
1.063 -
download
17
Transcript of Share Point Development With Unit Testing
![Page 1: Share Point Development With Unit Testing](https://reader036.fdocuments.in/reader036/viewer/2022081121/555caf08d8b42ab2358b5175/html5/thumbnails/1.jpg)
SHAREPOINT DEVELOPMENT
WITH UNIT TESTING
JEREMY THAKE
![Page 2: Share Point Development With Unit Testing](https://reader036.fdocuments.in/reader036/viewer/2022081121/555caf08d8b42ab2358b5175/html5/thumbnails/2.jpg)
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
![Page 3: Share Point Development With Unit Testing](https://reader036.fdocuments.in/reader036/viewer/2022081121/555caf08d8b42ab2358b5175/html5/thumbnails/3.jpg)
Unit Testing
Run quickly Run on every developer machine Minimal no config
(We are not testing MS code)
![Page 4: Share Point Development With Unit Testing](https://reader036.fdocuments.in/reader036/viewer/2022081121/555caf08d8b42ab2358b5175/html5/thumbnails/4.jpg)
Where to test?
ASP.NET Web FormsApplication Pages
Web Parts Event Receivers Feature Receivers Workflow coding activities Timer Jobs
![Page 5: Share Point Development With Unit Testing](https://reader036.fdocuments.in/reader036/viewer/2022081121/555caf08d8b42ab2358b5175/html5/thumbnails/5.jpg)
WHAT ITS NOT!
![Page 6: Share Point Development With Unit Testing](https://reader036.fdocuments.in/reader036/viewer/2022081121/555caf08d8b42ab2358b5175/html5/thumbnails/6.jpg)
UNIT TEST 101 SETUP
![Page 7: Share Point Development With Unit Testing](https://reader036.fdocuments.in/reader036/viewer/2022081121/555caf08d8b42ab2358b5175/html5/thumbnails/7.jpg)
TIGHTLY COUPLED CODE
![Page 8: Share Point Development With Unit Testing](https://reader036.fdocuments.in/reader036/viewer/2022081121/555caf08d8b42ab2358b5175/html5/thumbnails/8.jpg)
SharePoint + Mocking
Interfaces are rarely used Sealed classes Internal Constructors
TypeMock Isolator for SharePoint
![Page 9: Share Point Development With Unit Testing](https://reader036.fdocuments.in/reader036/viewer/2022081121/555caf08d8b42ab2358b5175/html5/thumbnails/9.jpg)
MOCKING 101
![Page 10: Share Point Development With Unit Testing](https://reader036.fdocuments.in/reader036/viewer/2022081121/555caf08d8b42ab2358b5175/html5/thumbnails/10.jpg)
NATURAL MOCKS
![Page 11: Share Point Development With Unit Testing](https://reader036.fdocuments.in/reader036/viewer/2022081121/555caf08d8b42ab2358b5175/html5/thumbnails/11.jpg)
SharePoint Guidance
![Page 12: Share Point Development With Unit Testing](https://reader036.fdocuments.in/reader036/viewer/2022081121/555caf08d8b42ab2358b5175/html5/thumbnails/12.jpg)
WRAPPERS & façades
![Page 13: Share Point Development With Unit Testing](https://reader036.fdocuments.in/reader036/viewer/2022081121/555caf08d8b42ab2358b5175/html5/thumbnails/13.jpg)
REPOSITORY
![Page 14: Share Point Development With Unit Testing](https://reader036.fdocuments.in/reader036/viewer/2022081121/555caf08d8b42ab2358b5175/html5/thumbnails/14.jpg)
MVP – Model View Presenter
![Page 15: Share Point Development With Unit Testing](https://reader036.fdocuments.in/reader036/viewer/2022081121/555caf08d8b42ab2358b5175/html5/thumbnails/15.jpg)
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
![Page 16: Share Point Development With Unit Testing](https://reader036.fdocuments.in/reader036/viewer/2022081121/555caf08d8b42ab2358b5175/html5/thumbnails/16.jpg)
MOCKING LARGE AREAS OF SHAREPOINT
![Page 17: Share Point Development With Unit Testing](https://reader036.fdocuments.in/reader036/viewer/2022081121/555caf08d8b42ab2358b5175/html5/thumbnails/17.jpg)
CONCLUSION It not easy
“Lots of code”
Benefitswhen refactoringother developers changing itenvironment dependencies reducedspeed
Doesn't stop poor quality code: list.Items.CountDispose()