share point development with unit testing

18
SHAREPOINT DEVELOPMENT WITH UNIT TESTING JEREMY THAKE

Upload: jeremy-thake

Post on 20-May-2015

1.063 views

Category:

Technology


17 download

TRANSCRIPT

Page 1: Share Point Development With Unit Testing

SHAREPOINT DEVELOPMENT

WITH UNIT TESTING

JEREMY THAKE

Page 2: Share Point Development With Unit Testing

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

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

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

WHAT ITS NOT!

Page 6: Share Point Development With Unit Testing

UNIT TEST 101 SETUP

Page 7: Share Point Development With Unit Testing

TIGHTLY COUPLED CODE

Page 8: Share Point Development With Unit Testing

SharePoint + Mocking

Interfaces are rarely used Sealed classes Internal Constructors

TypeMock Isolator for SharePoint

Page 9: Share Point Development With Unit Testing

MOCKING 101

Page 10: Share Point Development With Unit Testing

NATURAL MOCKS

Page 11: Share Point Development With Unit Testing

SharePoint Guidance

Page 12: Share Point Development With Unit Testing

WRAPPERS & façades

Page 13: Share Point Development With Unit Testing

REPOSITORY

Page 14: Share Point Development With Unit Testing

MVP – Model View Presenter

Page 15: Share Point Development With Unit Testing

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

MOCKING LARGE AREAS OF SHAREPOINT

Page 17: Share Point Development With Unit Testing

CONCLUSION It not easy

“Lots of code”

Benefitswhen refactoringother developers changing itenvironment dependencies reducedspeed

Doesn't stop poor quality code: list.Items.CountDispose()

Page 18: Share Point Development With Unit Testing

JEREMY THAKE

http://wss.made4the.net @jthake