Test Driven SharePoint Development DEV371 Andrew Woodward
<ul><li>Andrew Woodward, MVP </li></ul><ul><ul><li>Principal Consultant 21apps </li></ul></ul><ul><ul><li>Email  [email_ad...
Agenda <ul><li>What is TDD </li></ul><ul><li>Demo: My First TDD </li></ul><ul><li>SharePoint adds challenges </li></ul><ul...
What is TDD? <ul><li>T est  D riven  D evelopment  </li></ul><ul><ul><li>Or is it  Design ? </li></ul></ul><ul><ul><li>Or ...
10 Reasons TDD Sucks <ul><li>I never have enough time to write the tests,  once I’ve finished themain functionality </li><...
So what is TDD? <ul><li>As described by Uncle Bob in </li></ul><ul><li>‘ The Three Rules of TDD’* </li></ul>* Robert C Mar...
Rule 1 <ul><li>You are not allowed to write any production code unless it is to make a failing unit test pass. </li></ul>
Rule 2 <ul><li>You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures a...
Rule 3 <ul><li>You are not allowed to write any more production code than is sufficient to pass the one failing unit test....
You may be thinking <ul><li>This is stupid! </li></ul><ul><li>It will slow me down </li></ul><ul><li>This will stop me des...
Think about <ul><li>Code is working every minute </li></ul><ul><ul><li>Less debugging = less wasted time </li></ul></ul><u...
MY FIRST TDD <ul><li>Create a simple magic 8 ball web part using TDD </li></ul>
My First TDD <ul><li>Using 3 rules </li></ul><ul><li>Created Tests first to drive design </li></ul><ul><li>Refactored code...
MY FIRST TDD WITH SHAREPOINT <ul><li>Refactor the Magic 8 Ball web part to use SharePoint List </li></ul>
Custom 8 Ball Web Part <ul><li>Testing influenced design </li></ul><ul><ul><li>Designed from Public Interface </li></ul></...
Best Practice – Why? <ul><li>Improved quality </li></ul><ul><li>Less time debugging – lower cost </li></ul><ul><li>Cleaner...
Best Practice – When? <ul><li>You have commitment </li></ul><ul><li>Willing and able to invest time </li></ul><ul><li>You ...
Best Practice - Being Pragmatic <ul><li>TDD is hard to get started </li></ul><ul><ul><li>Easy to learn the 3 rules </li></...
Predication! <ul><li>2009 will be the year that SharePoint developers embrace Agile and TDD </li></ul>
Thank you for attending! Please be sure to fill out your session evaluation!
Thank you for attending! <ul><li>Post conference DVD with all slide decks </li></ul>Sponsored by
Upcoming SlideShare
Loading in …5
×

Test Driven Development with SharePoint

5,814 views
5,694 views

Published on

Provide an introduction to Test Driven Development (TDD), how TDD influences you design enhances the quality of the developed solution. We will look at the challenges faced in doing Unit Testing in a SharePoint environment and look at mocking out the core SharePoint object model elements using the new Typemock Isolator APIs. We will discuss some of the way you can approach TDD in your environment and the challenges you are like to face.

Published in: Technology
1 Comment
5 Likes
Statistics
Notes
No Downloads
Views
Total views
5,814
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
225
Comments
1
Likes
5
Embeds 0
No embeds

No notes for slide
  • Test Driven Development with SharePoint

    1. 1. Test Driven SharePoint Development DEV371 Andrew Woodward
    2. 2. <ul><li>Andrew Woodward, MVP </li></ul><ul><ul><li>Principal Consultant 21apps </li></ul></ul><ul><ul><li>Email [email_address] </li></ul></ul><ul><ul><li>Twitter @AndrewWoody </li></ul></ul><ul><ul><li>Blog www.andrewwoody.com/blog </li></ul></ul><ul><ul><li>Agile developer, recent white paper: Unit Testing SharePoint – Getting into the Object Model </li></ul></ul>
    3. 3. Agenda <ul><li>What is TDD </li></ul><ul><li>Demo: My First TDD </li></ul><ul><li>SharePoint adds challenges </li></ul><ul><li>Demo: My First TDD with SharePoint </li></ul><ul><li>Being Pragmatic </li></ul>
    4. 4. What is TDD? <ul><li>T est D riven D evelopment </li></ul><ul><ul><li>Or is it Design ? </li></ul></ul><ul><ul><li>Or BDD ? </li></ul></ul><ul><li>Started life in XP </li></ul><ul><ul><li>over 10 years ago! </li></ul></ul><ul><li>Has evolved over time </li></ul>
    5. 5. 10 Reasons TDD Sucks <ul><li>I never have enough time to write the tests, once I’ve finished themain functionality </li></ul><ul><li>Testing isn’t my job, because it’s QA’s job to make sure I do quality work . </li></ul><ul><li>Unit tests don’t help me, because my code works perfectly the first time . </li></ul><ul><li>There’s no need to test drive my code, because the design handed to me by the architect covers every possibility </li></ul><ul><li>Running the tests is a pain, because it takes too long to scan throughall of the output to see if everything was fine </li></ul><ul><li>Running the tests takes too long, because loading SharePointand restarting IIS between tests takes forever </li></ul><ul><li>I can’t do TDD, because you can’t unit test SharePoint </li></ul><ul><li>I don’t like TDD, because I enjoy the hours I spend in mydebugger </li></ul><ul><li>TDD is just a fad, and it’s completely unnecessary anyhow since projects always succeeded before </li></ul><ul><li>(BONUS) TDD sucks because I agree with all of the points here, and I don’t understand sarcasm . </li></ul>Quote From: Blue Sky on Mars Inspiration: Courtesy of AndersRask
    6. 6. So what is TDD? <ul><li>As described by Uncle Bob in </li></ul><ul><li>‘ The Three Rules of TDD’* </li></ul>* Robert C Martin, aka Uncle Bob
    7. 7. Rule 1 <ul><li>You are not allowed to write any production code unless it is to make a failing unit test pass. </li></ul>
    8. 8. Rule 2 <ul><li>You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failures. </li></ul>
    9. 9. Rule 3 <ul><li>You are not allowed to write any more production code than is sufficient to pass the one failing unit test. </li></ul>
    10. 10. You may be thinking <ul><li>This is stupid! </li></ul><ul><li>It will slow me down </li></ul><ul><li>This will stop me designing </li></ul><ul><li>This is &^@#% </li></ul>
    11. 11. Think about <ul><li>Code is working every minute </li></ul><ul><ul><li>Less debugging = less wasted time </li></ul></ul><ul><li>How many test created </li></ul><ul><ul><li>every hour, day, week, month, year </li></ul></ul><ul><li>Confidence to fix up messy code </li></ul><ul><li>Documented API examples </li></ul><ul><ul><li>Wouldn’t you love that for SharePoint </li></ul></ul>
    12. 12. MY FIRST TDD <ul><li>Create a simple magic 8 ball web part using TDD </li></ul>
    13. 13. My First TDD <ul><li>Using 3 rules </li></ul><ul><li>Created Tests first to drive design </li></ul><ul><li>Refactored code and tests </li></ul><ul><li>No extra code we didn’t need </li></ul>
    14. 14. MY FIRST TDD WITH SHAREPOINT <ul><li>Refactor the Magic 8 Ball web part to use SharePoint List </li></ul>
    15. 15. Custom 8 Ball Web Part <ul><li>Testing influenced design </li></ul><ul><ul><li>Designed from Public Interface </li></ul></ul><ul><li>SharePoint dependency </li></ul><ul><ul><li>Slow </li></ul></ul><ul><ul><li>Required Configuration </li></ul></ul><ul><li>Introduced Isolator </li></ul><ul><ul><li>Faked SharePoint objects </li></ul></ul><ul><ul><li>Focus on our logic </li></ul></ul>
    16. 16. Best Practice – Why? <ul><li>Improved quality </li></ul><ul><li>Less time debugging – lower cost </li></ul><ul><li>Cleaner code </li></ul><ul><li>Better design </li></ul><ul><ul><li>Initially and continually </li></ul></ul><ul><li>Documented by example </li></ul><ul><li>Automated tests </li></ul><ul><ul><li>Write once – run many times </li></ul></ul>
    17. 17. Best Practice – When? <ul><li>You have commitment </li></ul><ul><li>Willing and able to invest time </li></ul><ul><li>You understand Why? </li></ul>
    18. 18. Best Practice - Being Pragmatic <ul><li>TDD is hard to get started </li></ul><ul><ul><li>Easy to learn the 3 rules </li></ul></ul><ul><ul><li>Initially slow and awkward </li></ul></ul><ul><ul><li>Mindset change takes time </li></ul></ul><ul><li>Difficult to implement for Legacy code </li></ul><ul><li>Adoption takes time and investment </li></ul><ul><ul><li>Experience is invaluable </li></ul></ul><ul><li>However the rewards can be Profound </li></ul>
    19. 19. Predication! <ul><li>2009 will be the year that SharePoint developers embrace Agile and TDD </li></ul>
    20. 20. Thank you for attending! Please be sure to fill out your session evaluation!
    21. 21. Thank you for attending! <ul><li>Post conference DVD with all slide decks </li></ul>Sponsored by

    ×