Share Point Development With Unit Testing

Download Share Point Development With Unit Testing

Post on 20-May-2015

1.051 views

Category:

Technology

17 download

TRANSCRIPT

  • 1. SharePoint Development with Unit Testing
    JEREMY THAKE

2. 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
3. Unit Testing
Run quickly
Run on every developer machine
Minimal no config
(We are not testing MS code)
4. Where to test?
ASP.NET Web Forms
Application Pages
Web Parts
Event Receivers
Feature Receivers
Workflow coding activities
Timer Jobs
5. WHAT ITS NOT!
6. UNIT TEST 101 SETUP
7. TIGHTLY COUPLED CODE
8. SharePoint + Mocking
Interfaces are rarely used
Sealed classes
Internal Constructors
TypeMockIsolator for SharePoint
9. MOCKING 101
10. NATURAL MOCKS
11. SharePoint Guidance
12. WRAPPERS & faades
13. REPOSITORY
14. MVP Model View Presenter
15. 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
16. MOCKING LARGE AREAS OF SHAREPOINT
17. 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()
18. JEREMY THAKE
http://wss.made4the.net
@jthake