Test Driven Development with SharePoint

50 %
50 %
Information about Test Driven Development with SharePoint
Technology

Published on February 10, 2009

Author: AndrewWoody

Source: slideshare.net

Description

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.

Test Driven SharePoint Development DEV371 Andrew Woodward

Andrew Woodward, MVP Principal Consultant 21apps Email [email_address] Twitter @AndrewWoody Blog www.andrewwoody.com/blog Agile developer, recent white paper: Unit Testing SharePoint – Getting into the Object Model

Andrew Woodward, MVP

Principal Consultant 21apps

Email [email_address]

Twitter @AndrewWoody

Blog www.andrewwoody.com/blog

Agile developer, recent white paper: Unit Testing SharePoint – Getting into the Object Model

Agenda What is TDD Demo: My First TDD SharePoint adds challenges Demo: My First TDD with SharePoint Being Pragmatic

What is TDD

Demo: My First TDD

SharePoint adds challenges

Demo: My First TDD with SharePoint

Being Pragmatic

What is TDD? T est D riven D evelopment Or is it Design ? Or BDD ? Started life in XP over 10 years ago! Has evolved over time

T est D riven D evelopment

Or is it Design ?

Or BDD ?

Started life in XP

over 10 years ago!

Has evolved over time

10 Reasons TDD Sucks I never have enough time to write the tests, once I’ve finished themain functionality Testing isn’t my job, because it’s QA’s job to make sure I do quality work . Unit tests don’t help me, because my code works perfectly the first time . There’s no need to test drive my code, because the design handed to me by the architect covers every possibility Running the tests is a pain, because it takes too long to scan throughall of the output to see if everything was fine Running the tests takes too long, because loading SharePointand restarting IIS between tests takes forever I can’t do TDD, because you can’t unit test SharePoint I don’t like TDD, because I enjoy the hours I spend in mydebugger TDD is just a fad, and it’s completely unnecessary anyhow since projects always succeeded before (BONUS) TDD sucks because I agree with all of the points here, and I don’t understand sarcasm . Quote From: Blue Sky on Mars Inspiration: Courtesy of AndersRask

I never have enough time to write the tests, once I’ve finished themain functionality

Testing isn’t my job, because it’s QA’s job to make sure I do quality work .

Unit tests don’t help me, because my code works perfectly the first time .

There’s no need to test drive my code, because the design handed to me by the architect covers every possibility

Running the tests is a pain, because it takes too long to scan throughall of the output to see if everything was fine

Running the tests takes too long, because loading SharePointand restarting IIS between tests takes forever

I can’t do TDD, because you can’t unit test SharePoint

I don’t like TDD, because I enjoy the hours I spend in mydebugger

TDD is just a fad, and it’s completely unnecessary anyhow since projects always succeeded before

(BONUS) TDD sucks because I agree with all of the points here, and I don’t understand sarcasm .

So what is TDD? As described by Uncle Bob in ‘ The Three Rules of TDD’* * Robert C Martin, aka Uncle Bob

As described by Uncle Bob in

‘ The Three Rules of TDD’*

Rule 1 You are not allowed to write any production code unless it is to make a failing unit test pass.

You are not allowed to write any production code unless it is to make a failing unit test pass.

Rule 2 You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failures.

You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failures.

Rule 3 You are not allowed to write any more production code than is sufficient to pass the one failing unit test.

You are not allowed to write any more production code than is sufficient to pass the one failing unit test.

You may be thinking This is stupid! It will slow me down This will stop me designing This is &^@#%

This is stupid!

It will slow me down

This will stop me designing

This is &^@#%

Think about Code is working every minute Less debugging = less wasted time How many test created every hour, day, week, month, year Confidence to fix up messy code Documented API examples Wouldn’t you love that for SharePoint

Code is working every minute

Less debugging = less wasted time

How many test created

every hour, day, week, month, year

Confidence to fix up messy code

Documented API examples

Wouldn’t you love that for SharePoint

MY FIRST TDD Create a simple magic 8 ball web part using TDD

Create a simple magic 8 ball web part using TDD

My First TDD Using 3 rules Created Tests first to drive design Refactored code and tests No extra code we didn’t need

Using 3 rules

Created Tests first to drive design

Refactored code and tests

No extra code we didn’t need

MY FIRST TDD WITH SHAREPOINT Refactor the Magic 8 Ball web part to use SharePoint List

Refactor the Magic 8 Ball web part to use SharePoint List

Custom 8 Ball Web Part Testing influenced design Designed from Public Interface SharePoint dependency Slow Required Configuration Introduced Isolator Faked SharePoint objects Focus on our logic

Testing influenced design

Designed from Public Interface

SharePoint dependency

Slow

Required Configuration

Introduced Isolator

Faked SharePoint objects

Focus on our logic

Best Practice – Why? Improved quality Less time debugging – lower cost Cleaner code Better design Initially and continually Documented by example Automated tests Write once – run many times

Improved quality

Less time debugging – lower cost

Cleaner code

Better design

Initially and continually

Documented by example

Automated tests

Write once – run many times

Best Practice – When? You have commitment Willing and able to invest time You understand Why?

You have commitment

Willing and able to invest time

You understand Why?

Best Practice - Being Pragmatic TDD is hard to get started Easy to learn the 3 rules Initially slow and awkward Mindset change takes time Difficult to implement for Legacy code Adoption takes time and investment Experience is invaluable However the rewards can be Profound

TDD is hard to get started

Easy to learn the 3 rules

Initially slow and awkward

Mindset change takes time

Difficult to implement for Legacy code

Adoption takes time and investment

Experience is invaluable

However the rewards can be Profound

Predication! 2009 will be the year that SharePoint developers embrace Agile and TDD

2009 will be the year that SharePoint developers embrace Agile and TDD

Thank you for attending! Please be sure to fill out your session evaluation!

Thank you for attending! Post conference DVD with all slide decks Sponsored by

Post conference DVD with all slide decks

Add a comment

Related presentations

Related pages

Test Driven Development in SharePoint 2010

Hi, We would like to implement Test Driven Development(TDD) for SharePoint Development projects,Can anyone suggest me best articles /Tools for it?
Read more

Test-driven Development with SharePoint, Office 365 and ...

This session follows on from my Lean-Agile SharePoint Development talk in Copenhagen, 2013 and goes deeper into test-driven development (TDD) with ...
Read more

TDD for sharepoint - social.msdn.microsoft.com

I use Test Driven Development when doing my SharePoint development, but it can really only be done when developing custom things for SharePoint.
Read more

SPTDD: SharePoint and Test Driven Development, Part One ...

With the publication of the SharePoint Guidance code samples and documentation from the Microsoft Patterns and Practices group, the issue of Test Driven ...
Read more

Guidelines for Test-Driven Development

SharePoint Server 2013 ... System into test-driven development practices ... to a new test. Test-driven development forces critical analysis ...
Read more

Test-Driven Development - Microsoft Virtual Academy

Learn about Test-Driven Development, ... SharePoint Skype for Business ...
Read more

unit testing - Test Driven SharePoint Development - Stack ...

I agree with Larry, "normal" test-driven applies to SharePoint just fine. You should look at TypeMock for your unit / integration tests. It's a unit-test ...
Read more

Quick Start: Test Driven Development with Test Explorer

Writing Unit Tests for the .NET Framework with the Microsoft Unit Test Framework for Managed Code Quick Start: Test Driven Development with Test Explorer
Read more

Test-Driven-Development with SharePoint 2010 By Andreas ...

Test-Driven-Development with Sharepoint 2010 . Adhering to the principles of clean Software Design is not always an easy task. Using and understanding how ...
Read more