SlideShare une entreprise Scribd logo
1  sur  41
Test-driven Development with SharePoint
2013 and Visual Studio

Bill Ayers
MCM/MCSM SharePoint
MCTS, MCITP, MCSD, MCAD, MCSA, MCDBA,
MCT etc.
Professional Scrum Master (PSM I)
Consultant currently specialising in SharePoint
Development and Architecture for Web
Content Management

Blog: www.SPDoctor.net
E-mail: BillA@flosim.com
Twitter: @SPDoctor
Agenda:
Introduction to TDD
 Server-side tests
 Client-side tests
 ATDD
 Conclusions

Pre-historic Software Development
FORTRAN/COBOL
 Wish lists
 Ad-hoc development
 No source control!
 FORMAT statement

Waterfail
Requirements
Big design up-front
 Write-only documentation Design/Arch
Coding
 Analysis paralysis
 Wrong product
QA
 Over budget/time
 Project failure
Deployment



Maintenance
Agile
•

Individuals and interactions over processes and
tools

•

Working software over comprehensive
documentation

•

Customer collaboration over contract negotiation

•

Responding to change over following a plan

http://agilemanifesto.org/
The patterns and practices tag cloud
SharePoint is Different
Need some up-front architecture
decisions, certain types of artefact very
difficult to back out once in production (e.g.
list schema)
 Tight integration with the underlying platform
can make code inherently difficult to test

Extreme Programming - XP
Test-first development
 Pair programming
 Refactoring
 Continuous integration
 Frequent releases
 Coding standards
 Sustainable pace

What is TDD?
Goes beyond Test-first
 Tests drive the low-level design
 Supports refactoring
 Just a developer tool

TDD Cycle

requirements

write a
failing test

refactor
make test
pass
TDD rulebook

No code unless failing test
 Write just enough code to pass test
 No new test until green
 Refactoring must not add functionality
 Tests must be fast
 Tests must be easy to run (i.e. automated)
 Purpose of test should be clear
 Tests should be independent (run in any order)
 Test code is a first-class citizen

How does TDD work?

TDD is counter-intuitive
 Tests facilitate refactoring
 Refactoring facilitates incremental design
 Failing tests pinpoint problems quickly
 Fast (continuous) tests give immediate
feedback
 Tests should ideally isolate the code you are
working on
 Rapid feedback
 Less bugs

Refactoring
Clean up variable and function names for
clarity
 Make code more concise
 Remove spaghetti code
 Remove duplicate code
 Extract methods to avoid oversize methods
 Keep re-running the tests as you re-factor
 If test fails then Ctrl-Z, Ctrl-Z, Ctrl-Z …

Shopping List Story
Shopping List Story
As a team site user
 I want my shopping list visible on the home
page
 So that I don’t forget stuff


Acceptance Criteria:
•
•
•

Does a shopping list panel appear on the home page?
Does the panel show all items in the shopping list?
Are the items sorted alphabetically
Demo: TDD – Introduction
Benefits of TDD?














Less bugs
Better productivity (once the technique is learned)
Safe refactoring results in better code design
Cleaner design because enforces KISS and YAGNI
Improved code quality and confidence
Tests document the design
Easier to handle interruptions to “flow”
Incremental development
Test coverage
Enables future enhancement by ensuring existing functionality is
maintained (tests)
Strangely hypnotic, especially if you do it while listening to
progressive dance music
Drawbacks













Can be difficult to maintain discipline under pressure
Difficult in brownfield development
Difficult without management support
Excessive and trivial tests
False sense of security
Cost of maintaining tests
Not all development is equally suited to TDD
Not a silver bullet
Not appropriate for spikes or other non-production
code
Note all code is easy to test (e.g. SharePoint)
Types of tests
Test type

Spee
d

Unit

Requir
e
Code
Acces
s

Nee
d to
run
on
SP
Box

Suit Sui Sui Suit
TD t
t
Acce
D
De QA pt
v

Need
Tools
Isolatio
n f/w

FAST *

*

*

*

*

Integratio
n
(shallow)

MED

*

*

*

*

MSTest, NUnit

Integratio
n (deep)

SLO
W

*

*

*

MSTest, NUnit

UI

SLO
W

?

Manual

GLA
CIAL

*

*

*
(ATD
D)

MSTest, NUnit

VS (Coded
UI), Selenium,
Watin
Unit tests with SharePoint SSOM
– possible approaches (1)
Public methods, overrides of virtual
methods, etc.
 Isolate SharePoint calls within a Repository
class
 Service Locator pattern – P&P guidance
 Composite design patterns e.g. MVC/MVP, +
conventional mocks and stubs

Beware: Trivial Test Anti-pattern
Presenter:

string ShowMessage(string message, string name)
{
string messageresult = message + “ “ + name;
Return messageresult;
}
View:
Void RenderContents(..)
{
String message = ShowMessage(“Hello, “, SPContext.Current.User.Name);
textwriter.write(“<h1>” + message + “</h1>”);
}
Test class:
[TestMethod]
Void ShowMessage_returns_correct_message_string()
{
var presenter = new Presenter(_fakeView);
string actual = presenter.ShowMessage(“Hello,”, “Bill”);
Assert.AreEqual(“Hello, Bill”, actual);
}
Unit tests with SharePoint SSOM
– possible approaches (2)
Proprietary Mocking frameworks (Typemock
Isolator, JustMock, Microsoft Fakes f/w)
 Fake SharePoint framework (v. diff.)

Code Coverage (and other dubious metrics)
Your Custom
Code

SharePoint .NET

SharePoint Unmanaged
Code

ASP.NE
SQL
T Windows OS
Unit tests with SharePoint SSOM
– possible approaches (3)


Accept shallow integration tests in lieu
(“unigration tests”)
Demo: Server-side testing
Client-side testing
The new model – SharePoint-hosted Apps
 Unit testing JavaScript
 Faking the _api
 Shallow integration (“unigration”) tests


Surely this is the Java logo?
Options for client-side JavaScript testing
Ad-hoc tests (e.g. console logging)
 QUnit (qunitjs.com)






Jasmine




TDD style
BDD style

Mocha
BDD or TDD style
 PYO assertion library




UI tests (e.g. Selenium, VS UI tests)
Running tests
Can run tests in a browser window
 Chutzpah test runner


Command line and Visual Studio integration
 Only supports Jasmine and Qunit




For Continuous Integration use PhantomJS
Headless browser
 Chrome browser engine (WebKit)
 Phantomjs.org




Use a cloud test service for “cross-browser test”


Includes device browsers
Demo: Client-side testing
Tips for Testing JavaScript
Keep JavaScript modular in files,
not scattered amongst HTML
 To be able to Unit Test you need
units
 In JavaScript the unit of code
encapsulation is the function
 Very difficult to test an anonymous
function
 Very difficult to test a hidden
function – may need to
compromise encapsulation to
make testable
 Isolate tests from mark-up to avoid
fragility

The ATDD Cycle

User Story
Write
Acceptance
Tests

Acceptance
Tests Pass

Demo to PO
QA

write
test
refacto
r

pass
How does ATDD work?
Similar to BDD
 A DSL for business users to
define automated acceptance
tests
 Tooling such as
Fitnesse, SpecFlow
 Developer creates generic test
fixtures
 Can write tests first to drive
development (outer loop – inner
loop is TDD)
 Gives test team something to do

How do we do acceptance tests?







End-to-end testing
No requirement for tests to be fast (within reason)
Tools like SpecFlow can be used to define tests (but is it
worth it?)
More likely a QA professional will manually build
automated QA tests
Tools:



Selenium WebDriver
Visual Studio UI tests
End-to-end Testing









Best suited for acceptance tests
Drives application through the UI
Selenium WebDriver, Watin, Visual Studio
Can target different browsers
Fully tests DOM manipulation, JavaScript, interaction
with back-end (i.e. SharePoint)
These tests often written by a dedicated tester
Can be used for TDD but only if they are fast enough
Conclusions

Test Driven Development continues to gain
traction in the development community as a
whole and brings many benefits
 SharePoint challenges us to find new ways of
testing server-side code
 The SharePoint 2013 App model brings with it a
new world of client-side testing
 Good news: client-side code is easier to test than
server-side SharePoint code
 Some end-to-end testing will be necessary
particularly for acceptance tests

Recommended Reading:
“The Art of Unit Testing”, Roy Osherove
 www.extremeprogramming.org
 “Clean Code – A Handbook of Agile Software
Craftsmanship”, Robert C Martin
 Lean-Agile Acceptance Test-Driven
Development, Ken Pugh

Contact me:

Blog: www.spdoctor.net
 Twitter: @spdoctor
 Sharepoint.stackexchange.com
(moderator)
 Email: BillA@flosim.com

SPCA2013 - Test-driven Development with SharePoint 2013 and Visual Studio
SPCA2013 - Test-driven Development with SharePoint 2013 and Visual Studio

Contenu connexe

Tendances

TDD And Refactoring
TDD And RefactoringTDD And Refactoring
TDD And RefactoringNaresh Jain
 
Codeception Testing Framework -- English #phpkansai
Codeception Testing Framework -- English #phpkansaiCodeception Testing Framework -- English #phpkansai
Codeception Testing Framework -- English #phpkansaiFlorent Batard
 
Pragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptPragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptdavejohnson
 
Code Quality Practice and Tools
Code Quality Practice and ToolsCode Quality Practice and Tools
Code Quality Practice and ToolsBob Paulin
 
Professional Code Reviews - Bogdan Gusiev
Professional Code Reviews - Bogdan GusievProfessional Code Reviews - Bogdan Gusiev
Professional Code Reviews - Bogdan GusievRuby Meditation
 
PHPConf.asia 2016 - BDD with Behat for Beginners
PHPConf.asia 2016 - BDD with Behat for BeginnersPHPConf.asia 2016 - BDD with Behat for Beginners
PHPConf.asia 2016 - BDD with Behat for BeginnersAdam Englander
 
Introducing Keyword-Driven Test Automation
Introducing Keyword-Driven Test AutomationIntroducing Keyword-Driven Test Automation
Introducing Keyword-Driven Test AutomationTechWell
 
Behavior Driven Development with SpecFlow
Behavior Driven Development with SpecFlowBehavior Driven Development with SpecFlow
Behavior Driven Development with SpecFlowRachid Kherrazi
 
Realtime selenium interview questions
Realtime selenium interview questionsRealtime selenium interview questions
Realtime selenium interview questionsKuldeep Pawar
 
Introducing Keyword-driven Test Automation
Introducing Keyword-driven Test AutomationIntroducing Keyword-driven Test Automation
Introducing Keyword-driven Test AutomationTechWell
 
Test-Driven Development (TDD)
Test-Driven Development (TDD)Test-Driven Development (TDD)
Test-Driven Development (TDD)Brian Rasmussen
 
SoftTest Ireland: Model Based Testing - January 27th 2011
SoftTest Ireland: Model Based Testing - January 27th 2011SoftTest Ireland: Model Based Testing - January 27th 2011
SoftTest Ireland: Model Based Testing - January 27th 2011David O'Dowd
 
Test Automation Framework Development Introduction
Test Automation Framework Development IntroductionTest Automation Framework Development Introduction
Test Automation Framework Development IntroductionGanuka Yashantha
 
AD208 - End to End Quality Processes for Top Notch XPages Apps
AD208 - End to End Quality Processes for Top Notch XPages AppsAD208 - End to End Quality Processes for Top Notch XPages Apps
AD208 - End to End Quality Processes for Top Notch XPages Appsbeglee
 
Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016
Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016
Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016Steven Smith
 

Tendances (20)

Test Automation and Keyword-driven testing af Brian Nielsen, CISS/AAU
Test Automation and Keyword-driven testing af Brian Nielsen, CISS/AAUTest Automation and Keyword-driven testing af Brian Nielsen, CISS/AAU
Test Automation and Keyword-driven testing af Brian Nielsen, CISS/AAU
 
TDD And Refactoring
TDD And RefactoringTDD And Refactoring
TDD And Refactoring
 
Codeception Testing Framework -- English #phpkansai
Codeception Testing Framework -- English #phpkansaiCodeception Testing Framework -- English #phpkansai
Codeception Testing Framework -- English #phpkansai
 
Using Specflow for BDD
Using Specflow for BDDUsing Specflow for BDD
Using Specflow for BDD
 
Pragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptPragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScript
 
Code Quality Practice and Tools
Code Quality Practice and ToolsCode Quality Practice and Tools
Code Quality Practice and Tools
 
Professional Code Reviews - Bogdan Gusiev
Professional Code Reviews - Bogdan GusievProfessional Code Reviews - Bogdan Gusiev
Professional Code Reviews - Bogdan Gusiev
 
PHPConf.asia 2016 - BDD with Behat for Beginners
PHPConf.asia 2016 - BDD with Behat for BeginnersPHPConf.asia 2016 - BDD with Behat for Beginners
PHPConf.asia 2016 - BDD with Behat for Beginners
 
Introducing Keyword-Driven Test Automation
Introducing Keyword-Driven Test AutomationIntroducing Keyword-Driven Test Automation
Introducing Keyword-Driven Test Automation
 
Behavior Driven Development with SpecFlow
Behavior Driven Development with SpecFlowBehavior Driven Development with SpecFlow
Behavior Driven Development with SpecFlow
 
Testing In Java
Testing In JavaTesting In Java
Testing In Java
 
Realtime selenium interview questions
Realtime selenium interview questionsRealtime selenium interview questions
Realtime selenium interview questions
 
Introducing Keyword-driven Test Automation
Introducing Keyword-driven Test AutomationIntroducing Keyword-driven Test Automation
Introducing Keyword-driven Test Automation
 
Test-Driven Development (TDD)
Test-Driven Development (TDD)Test-Driven Development (TDD)
Test-Driven Development (TDD)
 
SoftTest Ireland: Model Based Testing - January 27th 2011
SoftTest Ireland: Model Based Testing - January 27th 2011SoftTest Ireland: Model Based Testing - January 27th 2011
SoftTest Ireland: Model Based Testing - January 27th 2011
 
Test Automation Framework Development Introduction
Test Automation Framework Development IntroductionTest Automation Framework Development Introduction
Test Automation Framework Development Introduction
 
Automated Testing
Automated TestingAutomated Testing
Automated Testing
 
AD208 - End to End Quality Processes for Top Notch XPages Apps
AD208 - End to End Quality Processes for Top Notch XPages AppsAD208 - End to End Quality Processes for Top Notch XPages Apps
AD208 - End to End Quality Processes for Top Notch XPages Apps
 
Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016
Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016
Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016
 
The Testing Planet - July 2010
The Testing Planet - July 2010The Testing Planet - July 2010
The Testing Planet - July 2010
 

Similaire à SPCA2013 - Test-driven Development with SharePoint 2013 and Visual Studio

Test team dynamics, Антон Мужайло
Test team dynamics, Антон МужайлоTest team dynamics, Антон Мужайло
Test team dynamics, Антон МужайлоSigma Software
 
Introducing TDD to your project
Introducing TDD to your projectIntroducing TDD to your project
Introducing TDD to your projectBastian Feder
 
Odd E验收测试驱动开发实战
Odd E验收测试驱动开发实战Odd E验收测试驱动开发实战
Odd E验收测试驱动开发实战George Ang
 
Test Automation Best Practices (with SOA test approach)
Test Automation Best Practices (with SOA test approach)Test Automation Best Practices (with SOA test approach)
Test Automation Best Practices (with SOA test approach)Leonard Fingerman
 
Whats New In 2010 (Msdn & Visual Studio)
Whats New In 2010 (Msdn & Visual Studio)Whats New In 2010 (Msdn & Visual Studio)
Whats New In 2010 (Msdn & Visual Studio)Steve Lange
 
Behaviour Driven Development V 0.1
Behaviour Driven Development V 0.1Behaviour Driven Development V 0.1
Behaviour Driven Development V 0.1willmation
 
Team Foundation Server 2010 - Overview
Team Foundation Server 2010 - OverviewTeam Foundation Server 2010 - Overview
Team Foundation Server 2010 - OverviewSteve Lange
 
Large scale agile development practices
Large scale agile development practicesLarge scale agile development practices
Large scale agile development practicesSkills Matter
 
Pragmatic Architecture in .NET
Pragmatic Architecture in .NETPragmatic Architecture in .NET
Pragmatic Architecture in .NEThousecor
 
The Magic Of Application Lifecycle Management In Vs Public
The Magic Of Application Lifecycle Management In Vs PublicThe Magic Of Application Lifecycle Management In Vs Public
The Magic Of Application Lifecycle Management In Vs PublicDavid Solivan
 
Building Scalable Development Environments
Building Scalable Development EnvironmentsBuilding Scalable Development Environments
Building Scalable Development EnvironmentsShahar Evron
 
#SPSToronto How to do #DevOps with #SPFx and why it matters
#SPSToronto How to do #DevOps with #SPFx and why it matters#SPSToronto How to do #DevOps with #SPFx and why it matters
#SPSToronto How to do #DevOps with #SPFx and why it mattersVincent Biret
 
A Lap Around Visual Studio 2010
A Lap Around Visual Studio 2010A Lap Around Visual Studio 2010
A Lap Around Visual Studio 2010Abram John Limpin
 
Agile Development in .NET
Agile Development in .NETAgile Development in .NET
Agile Development in .NETdanhermes
 
Application Lifecycle Management with TFS
Application Lifecycle Management with TFSApplication Lifecycle Management with TFS
Application Lifecycle Management with TFSMehdi Khalili
 
Lap Around Visual Studio 2010 Ultimate And TFS 2010
Lap Around Visual Studio 2010 Ultimate And TFS 2010Lap Around Visual Studio 2010 Ultimate And TFS 2010
Lap Around Visual Studio 2010 Ultimate And TFS 2010Ed Blankenship
 
Test driven development v1.0
Test driven development v1.0Test driven development v1.0
Test driven development v1.0Ganesh Kondal
 
ATDD in Practice
ATDD in PracticeATDD in Practice
ATDD in PracticeSteven Mak
 

Similaire à SPCA2013 - Test-driven Development with SharePoint 2013 and Visual Studio (20)

Test team dynamics, Антон Мужайло
Test team dynamics, Антон МужайлоTest team dynamics, Антон Мужайло
Test team dynamics, Антон Мужайло
 
Introducing TDD to your project
Introducing TDD to your projectIntroducing TDD to your project
Introducing TDD to your project
 
Odd E验收测试驱动开发实战
Odd E验收测试驱动开发实战Odd E验收测试驱动开发实战
Odd E验收测试驱动开发实战
 
Test Automation Best Practices (with SOA test approach)
Test Automation Best Practices (with SOA test approach)Test Automation Best Practices (with SOA test approach)
Test Automation Best Practices (with SOA test approach)
 
Whats New In 2010 (Msdn & Visual Studio)
Whats New In 2010 (Msdn & Visual Studio)Whats New In 2010 (Msdn & Visual Studio)
Whats New In 2010 (Msdn & Visual Studio)
 
VS 2010 codename Rosario
VS 2010 codename RosarioVS 2010 codename Rosario
VS 2010 codename Rosario
 
Vsts 2
Vsts 2Vsts 2
Vsts 2
 
Behaviour Driven Development V 0.1
Behaviour Driven Development V 0.1Behaviour Driven Development V 0.1
Behaviour Driven Development V 0.1
 
Team Foundation Server 2010 - Overview
Team Foundation Server 2010 - OverviewTeam Foundation Server 2010 - Overview
Team Foundation Server 2010 - Overview
 
Large scale agile development practices
Large scale agile development practicesLarge scale agile development practices
Large scale agile development practices
 
Pragmatic Architecture in .NET
Pragmatic Architecture in .NETPragmatic Architecture in .NET
Pragmatic Architecture in .NET
 
The Magic Of Application Lifecycle Management In Vs Public
The Magic Of Application Lifecycle Management In Vs PublicThe Magic Of Application Lifecycle Management In Vs Public
The Magic Of Application Lifecycle Management In Vs Public
 
Building Scalable Development Environments
Building Scalable Development EnvironmentsBuilding Scalable Development Environments
Building Scalable Development Environments
 
#SPSToronto How to do #DevOps with #SPFx and why it matters
#SPSToronto How to do #DevOps with #SPFx and why it matters#SPSToronto How to do #DevOps with #SPFx and why it matters
#SPSToronto How to do #DevOps with #SPFx and why it matters
 
A Lap Around Visual Studio 2010
A Lap Around Visual Studio 2010A Lap Around Visual Studio 2010
A Lap Around Visual Studio 2010
 
Agile Development in .NET
Agile Development in .NETAgile Development in .NET
Agile Development in .NET
 
Application Lifecycle Management with TFS
Application Lifecycle Management with TFSApplication Lifecycle Management with TFS
Application Lifecycle Management with TFS
 
Lap Around Visual Studio 2010 Ultimate And TFS 2010
Lap Around Visual Studio 2010 Ultimate And TFS 2010Lap Around Visual Studio 2010 Ultimate And TFS 2010
Lap Around Visual Studio 2010 Ultimate And TFS 2010
 
Test driven development v1.0
Test driven development v1.0Test driven development v1.0
Test driven development v1.0
 
ATDD in Practice
ATDD in PracticeATDD in Practice
ATDD in Practice
 

Plus de NCCOMMS

O365Con19 - UI:UX 101 Learn How to Design Custom Experiences for SharePoint -...
O365Con19 - UI:UX 101 Learn How to Design Custom Experiences for SharePoint -...O365Con19 - UI:UX 101 Learn How to Design Custom Experiences for SharePoint -...
O365Con19 - UI:UX 101 Learn How to Design Custom Experiences for SharePoint -...NCCOMMS
 
O365Con19 - Model-driven Apps or Canvas Apps? - Rick Bakker
O365Con19 - Model-driven Apps or Canvas Apps? - Rick BakkerO365Con19 - Model-driven Apps or Canvas Apps? - Rick Bakker
O365Con19 - Model-driven Apps or Canvas Apps? - Rick BakkerNCCOMMS
 
O365Con19 - Office 365 Groups Surviving the Real World - Jasper Oosterveld
O365Con19 - Office 365 Groups Surviving the Real World - Jasper OosterveldO365Con19 - Office 365 Groups Surviving the Real World - Jasper Oosterveld
O365Con19 - Office 365 Groups Surviving the Real World - Jasper OosterveldNCCOMMS
 
O365Con19 - Developing Timerjob and Eventhandler Equivalents - Adis Jugo
O365Con19 - Developing Timerjob and Eventhandler Equivalents - Adis JugoO365Con19 - Developing Timerjob and Eventhandler Equivalents - Adis Jugo
O365Con19 - Developing Timerjob and Eventhandler Equivalents - Adis JugoNCCOMMS
 
O365Con19 - Sharepoint with (Artificial) Intelligence - Adis Jugo
O365Con19 - Sharepoint with (Artificial) Intelligence - Adis JugoO365Con19 - Sharepoint with (Artificial) Intelligence - Adis Jugo
O365Con19 - Sharepoint with (Artificial) Intelligence - Adis JugoNCCOMMS
 
O365Con19 - What Do You Mean 90 days Isn't Enough - Paul Hunt
O365Con19 - What Do You Mean 90 days Isn't Enough - Paul HuntO365Con19 - What Do You Mean 90 days Isn't Enough - Paul Hunt
O365Con19 - What Do You Mean 90 days Isn't Enough - Paul HuntNCCOMMS
 
O365Con19 - Tips and Tricks for Complex Migrations to SharePoint Online - And...
O365Con19 - Tips and Tricks for Complex Migrations to SharePoint Online - And...O365Con19 - Tips and Tricks for Complex Migrations to SharePoint Online - And...
O365Con19 - Tips and Tricks for Complex Migrations to SharePoint Online - And...NCCOMMS
 
O365Con19 - Start Developing Teams Tabs and SharePoint Webparts with SPFX - O...
O365Con19 - Start Developing Teams Tabs and SharePoint Webparts with SPFX - O...O365Con19 - Start Developing Teams Tabs and SharePoint Webparts with SPFX - O...
O365Con19 - Start Developing Teams Tabs and SharePoint Webparts with SPFX - O...NCCOMMS
 
O365Con19 - Start Your Journey from Skype for Business to Teams - Sasja Beere...
O365Con19 - Start Your Journey from Skype for Business to Teams - Sasja Beere...O365Con19 - Start Your Journey from Skype for Business to Teams - Sasja Beere...
O365Con19 - Start Your Journey from Skype for Business to Teams - Sasja Beere...NCCOMMS
 
O365Con19 - Lets Get Started with Azure Container Instances - Jussi Roine
O365Con19 - Lets Get Started with Azure Container Instances - Jussi RoineO365Con19 - Lets Get Started with Azure Container Instances - Jussi Roine
O365Con19 - Lets Get Started with Azure Container Instances - Jussi RoineNCCOMMS
 
O365Con19 - Azure Blackbelt - Jussi Roine
O365Con19 - Azure Blackbelt - Jussi RoineO365Con19 - Azure Blackbelt - Jussi Roine
O365Con19 - Azure Blackbelt - Jussi RoineNCCOMMS
 
O365Con19 - Customise the UI in Modern SharePoint Workspaces - Corinna Lins
O365Con19 - Customise the UI in Modern SharePoint Workspaces - Corinna LinsO365Con19 - Customise the UI in Modern SharePoint Workspaces - Corinna Lins
O365Con19 - Customise the UI in Modern SharePoint Workspaces - Corinna LinsNCCOMMS
 
O365Con19 - Be The Protagonist of Your Modern Workplace - Corinna Lins
O365Con19 - Be The Protagonist of Your Modern Workplace - Corinna LinsO365Con19 - Be The Protagonist of Your Modern Workplace - Corinna Lins
O365Con19 - Be The Protagonist of Your Modern Workplace - Corinna LinsNCCOMMS
 
O365Con19 - How to Really Manage all your Tasks Across Microsoft 365 - Luise ...
O365Con19 - How to Really Manage all your Tasks Across Microsoft 365 - Luise ...O365Con19 - How to Really Manage all your Tasks Across Microsoft 365 - Luise ...
O365Con19 - How to Really Manage all your Tasks Across Microsoft 365 - Luise ...NCCOMMS
 
O365Con19 - Sharing Code Efficiently in your Organisation - Elio Struyf
O365Con19 - Sharing Code Efficiently in your Organisation - Elio StruyfO365Con19 - Sharing Code Efficiently in your Organisation - Elio Struyf
O365Con19 - Sharing Code Efficiently in your Organisation - Elio StruyfNCCOMMS
 
O365Con19 - Things I've Learned While Building a Product on SharePoint Modern...
O365Con19 - Things I've Learned While Building a Product on SharePoint Modern...O365Con19 - Things I've Learned While Building a Product on SharePoint Modern...
O365Con19 - Things I've Learned While Building a Product on SharePoint Modern...NCCOMMS
 
O365Con19 - Keep Control of Your Data with AIP and CA - Bram de Jager
O365Con19 - Keep Control of Your Data with AIP and CA - Bram de JagerO365Con19 - Keep Control of Your Data with AIP and CA - Bram de Jager
O365Con19 - Keep Control of Your Data with AIP and CA - Bram de JagerNCCOMMS
 
O365Con19 - Kaizala a Dive Into the Unknown - Rick van Rousselt
O365Con19 - Kaizala a Dive Into the Unknown - Rick van RousseltO365Con19 - Kaizala a Dive Into the Unknown - Rick van Rousselt
O365Con19 - Kaizala a Dive Into the Unknown - Rick van RousseltNCCOMMS
 
O365Con19 - How to Inspire Users to Unstick from Email - Luise Freese
O365Con19 - How to Inspire Users to Unstick from Email - Luise FreeseO365Con19 - How to Inspire Users to Unstick from Email - Luise Freese
O365Con19 - How to Inspire Users to Unstick from Email - Luise FreeseNCCOMMS
 
O365Con19 - O365 Identity Management and The Golden Config - Chris Goosen
O365Con19 - O365 Identity Management and The Golden Config - Chris GoosenO365Con19 - O365 Identity Management and The Golden Config - Chris Goosen
O365Con19 - O365 Identity Management and The Golden Config - Chris GoosenNCCOMMS
 

Plus de NCCOMMS (20)

O365Con19 - UI:UX 101 Learn How to Design Custom Experiences for SharePoint -...
O365Con19 - UI:UX 101 Learn How to Design Custom Experiences for SharePoint -...O365Con19 - UI:UX 101 Learn How to Design Custom Experiences for SharePoint -...
O365Con19 - UI:UX 101 Learn How to Design Custom Experiences for SharePoint -...
 
O365Con19 - Model-driven Apps or Canvas Apps? - Rick Bakker
O365Con19 - Model-driven Apps or Canvas Apps? - Rick BakkerO365Con19 - Model-driven Apps or Canvas Apps? - Rick Bakker
O365Con19 - Model-driven Apps or Canvas Apps? - Rick Bakker
 
O365Con19 - Office 365 Groups Surviving the Real World - Jasper Oosterveld
O365Con19 - Office 365 Groups Surviving the Real World - Jasper OosterveldO365Con19 - Office 365 Groups Surviving the Real World - Jasper Oosterveld
O365Con19 - Office 365 Groups Surviving the Real World - Jasper Oosterveld
 
O365Con19 - Developing Timerjob and Eventhandler Equivalents - Adis Jugo
O365Con19 - Developing Timerjob and Eventhandler Equivalents - Adis JugoO365Con19 - Developing Timerjob and Eventhandler Equivalents - Adis Jugo
O365Con19 - Developing Timerjob and Eventhandler Equivalents - Adis Jugo
 
O365Con19 - Sharepoint with (Artificial) Intelligence - Adis Jugo
O365Con19 - Sharepoint with (Artificial) Intelligence - Adis JugoO365Con19 - Sharepoint with (Artificial) Intelligence - Adis Jugo
O365Con19 - Sharepoint with (Artificial) Intelligence - Adis Jugo
 
O365Con19 - What Do You Mean 90 days Isn't Enough - Paul Hunt
O365Con19 - What Do You Mean 90 days Isn't Enough - Paul HuntO365Con19 - What Do You Mean 90 days Isn't Enough - Paul Hunt
O365Con19 - What Do You Mean 90 days Isn't Enough - Paul Hunt
 
O365Con19 - Tips and Tricks for Complex Migrations to SharePoint Online - And...
O365Con19 - Tips and Tricks for Complex Migrations to SharePoint Online - And...O365Con19 - Tips and Tricks for Complex Migrations to SharePoint Online - And...
O365Con19 - Tips and Tricks for Complex Migrations to SharePoint Online - And...
 
O365Con19 - Start Developing Teams Tabs and SharePoint Webparts with SPFX - O...
O365Con19 - Start Developing Teams Tabs and SharePoint Webparts with SPFX - O...O365Con19 - Start Developing Teams Tabs and SharePoint Webparts with SPFX - O...
O365Con19 - Start Developing Teams Tabs and SharePoint Webparts with SPFX - O...
 
O365Con19 - Start Your Journey from Skype for Business to Teams - Sasja Beere...
O365Con19 - Start Your Journey from Skype for Business to Teams - Sasja Beere...O365Con19 - Start Your Journey from Skype for Business to Teams - Sasja Beere...
O365Con19 - Start Your Journey from Skype for Business to Teams - Sasja Beere...
 
O365Con19 - Lets Get Started with Azure Container Instances - Jussi Roine
O365Con19 - Lets Get Started with Azure Container Instances - Jussi RoineO365Con19 - Lets Get Started with Azure Container Instances - Jussi Roine
O365Con19 - Lets Get Started with Azure Container Instances - Jussi Roine
 
O365Con19 - Azure Blackbelt - Jussi Roine
O365Con19 - Azure Blackbelt - Jussi RoineO365Con19 - Azure Blackbelt - Jussi Roine
O365Con19 - Azure Blackbelt - Jussi Roine
 
O365Con19 - Customise the UI in Modern SharePoint Workspaces - Corinna Lins
O365Con19 - Customise the UI in Modern SharePoint Workspaces - Corinna LinsO365Con19 - Customise the UI in Modern SharePoint Workspaces - Corinna Lins
O365Con19 - Customise the UI in Modern SharePoint Workspaces - Corinna Lins
 
O365Con19 - Be The Protagonist of Your Modern Workplace - Corinna Lins
O365Con19 - Be The Protagonist of Your Modern Workplace - Corinna LinsO365Con19 - Be The Protagonist of Your Modern Workplace - Corinna Lins
O365Con19 - Be The Protagonist of Your Modern Workplace - Corinna Lins
 
O365Con19 - How to Really Manage all your Tasks Across Microsoft 365 - Luise ...
O365Con19 - How to Really Manage all your Tasks Across Microsoft 365 - Luise ...O365Con19 - How to Really Manage all your Tasks Across Microsoft 365 - Luise ...
O365Con19 - How to Really Manage all your Tasks Across Microsoft 365 - Luise ...
 
O365Con19 - Sharing Code Efficiently in your Organisation - Elio Struyf
O365Con19 - Sharing Code Efficiently in your Organisation - Elio StruyfO365Con19 - Sharing Code Efficiently in your Organisation - Elio Struyf
O365Con19 - Sharing Code Efficiently in your Organisation - Elio Struyf
 
O365Con19 - Things I've Learned While Building a Product on SharePoint Modern...
O365Con19 - Things I've Learned While Building a Product on SharePoint Modern...O365Con19 - Things I've Learned While Building a Product on SharePoint Modern...
O365Con19 - Things I've Learned While Building a Product on SharePoint Modern...
 
O365Con19 - Keep Control of Your Data with AIP and CA - Bram de Jager
O365Con19 - Keep Control of Your Data with AIP and CA - Bram de JagerO365Con19 - Keep Control of Your Data with AIP and CA - Bram de Jager
O365Con19 - Keep Control of Your Data with AIP and CA - Bram de Jager
 
O365Con19 - Kaizala a Dive Into the Unknown - Rick van Rousselt
O365Con19 - Kaizala a Dive Into the Unknown - Rick van RousseltO365Con19 - Kaizala a Dive Into the Unknown - Rick van Rousselt
O365Con19 - Kaizala a Dive Into the Unknown - Rick van Rousselt
 
O365Con19 - How to Inspire Users to Unstick from Email - Luise Freese
O365Con19 - How to Inspire Users to Unstick from Email - Luise FreeseO365Con19 - How to Inspire Users to Unstick from Email - Luise Freese
O365Con19 - How to Inspire Users to Unstick from Email - Luise Freese
 
O365Con19 - O365 Identity Management and The Golden Config - Chris Goosen
O365Con19 - O365 Identity Management and The Golden Config - Chris GoosenO365Con19 - O365 Identity Management and The Golden Config - Chris Goosen
O365Con19 - O365 Identity Management and The Golden Config - Chris Goosen
 

Dernier

Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 

Dernier (20)

Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 

SPCA2013 - Test-driven Development with SharePoint 2013 and Visual Studio

  • 1.
  • 2. Test-driven Development with SharePoint 2013 and Visual Studio Bill Ayers
  • 3. MCM/MCSM SharePoint MCTS, MCITP, MCSD, MCAD, MCSA, MCDBA, MCT etc. Professional Scrum Master (PSM I) Consultant currently specialising in SharePoint Development and Architecture for Web Content Management Blog: www.SPDoctor.net E-mail: BillA@flosim.com Twitter: @SPDoctor
  • 4. Agenda: Introduction to TDD  Server-side tests  Client-side tests  ATDD  Conclusions 
  • 5. Pre-historic Software Development FORTRAN/COBOL  Wish lists  Ad-hoc development  No source control!  FORMAT statement 
  • 6. Waterfail Requirements Big design up-front  Write-only documentation Design/Arch Coding  Analysis paralysis  Wrong product QA  Over budget/time  Project failure Deployment  Maintenance
  • 7. Agile • Individuals and interactions over processes and tools • Working software over comprehensive documentation • Customer collaboration over contract negotiation • Responding to change over following a plan http://agilemanifesto.org/
  • 8. The patterns and practices tag cloud
  • 9. SharePoint is Different Need some up-front architecture decisions, certain types of artefact very difficult to back out once in production (e.g. list schema)  Tight integration with the underlying platform can make code inherently difficult to test 
  • 10. Extreme Programming - XP Test-first development  Pair programming  Refactoring  Continuous integration  Frequent releases  Coding standards  Sustainable pace 
  • 11. What is TDD? Goes beyond Test-first  Tests drive the low-level design  Supports refactoring  Just a developer tool 
  • 12. TDD Cycle requirements write a failing test refactor make test pass
  • 13. TDD rulebook No code unless failing test  Write just enough code to pass test  No new test until green  Refactoring must not add functionality  Tests must be fast  Tests must be easy to run (i.e. automated)  Purpose of test should be clear  Tests should be independent (run in any order)  Test code is a first-class citizen 
  • 14. How does TDD work? TDD is counter-intuitive  Tests facilitate refactoring  Refactoring facilitates incremental design  Failing tests pinpoint problems quickly  Fast (continuous) tests give immediate feedback  Tests should ideally isolate the code you are working on  Rapid feedback  Less bugs 
  • 15. Refactoring Clean up variable and function names for clarity  Make code more concise  Remove spaghetti code  Remove duplicate code  Extract methods to avoid oversize methods  Keep re-running the tests as you re-factor  If test fails then Ctrl-Z, Ctrl-Z, Ctrl-Z … 
  • 17. Shopping List Story As a team site user  I want my shopping list visible on the home page  So that I don’t forget stuff  Acceptance Criteria: • • • Does a shopping list panel appear on the home page? Does the panel show all items in the shopping list? Are the items sorted alphabetically
  • 18. Demo: TDD – Introduction
  • 19. Benefits of TDD?            Less bugs Better productivity (once the technique is learned) Safe refactoring results in better code design Cleaner design because enforces KISS and YAGNI Improved code quality and confidence Tests document the design Easier to handle interruptions to “flow” Incremental development Test coverage Enables future enhancement by ensuring existing functionality is maintained (tests) Strangely hypnotic, especially if you do it while listening to progressive dance music
  • 20. Drawbacks           Can be difficult to maintain discipline under pressure Difficult in brownfield development Difficult without management support Excessive and trivial tests False sense of security Cost of maintaining tests Not all development is equally suited to TDD Not a silver bullet Not appropriate for spikes or other non-production code Note all code is easy to test (e.g. SharePoint)
  • 21. Types of tests Test type Spee d Unit Requir e Code Acces s Nee d to run on SP Box Suit Sui Sui Suit TD t t Acce D De QA pt v Need Tools Isolatio n f/w FAST * * * * * Integratio n (shallow) MED * * * * MSTest, NUnit Integratio n (deep) SLO W * * * MSTest, NUnit UI SLO W ? Manual GLA CIAL * * * (ATD D) MSTest, NUnit VS (Coded UI), Selenium, Watin
  • 22. Unit tests with SharePoint SSOM – possible approaches (1) Public methods, overrides of virtual methods, etc.  Isolate SharePoint calls within a Repository class  Service Locator pattern – P&P guidance  Composite design patterns e.g. MVC/MVP, + conventional mocks and stubs 
  • 23. Beware: Trivial Test Anti-pattern Presenter: string ShowMessage(string message, string name) { string messageresult = message + “ “ + name; Return messageresult; } View: Void RenderContents(..) { String message = ShowMessage(“Hello, “, SPContext.Current.User.Name); textwriter.write(“<h1>” + message + “</h1>”); } Test class: [TestMethod] Void ShowMessage_returns_correct_message_string() { var presenter = new Presenter(_fakeView); string actual = presenter.ShowMessage(“Hello,”, “Bill”); Assert.AreEqual(“Hello, Bill”, actual); }
  • 24. Unit tests with SharePoint SSOM – possible approaches (2) Proprietary Mocking frameworks (Typemock Isolator, JustMock, Microsoft Fakes f/w)  Fake SharePoint framework (v. diff.) 
  • 25. Code Coverage (and other dubious metrics) Your Custom Code SharePoint .NET SharePoint Unmanaged Code ASP.NE SQL T Windows OS
  • 26. Unit tests with SharePoint SSOM – possible approaches (3)  Accept shallow integration tests in lieu (“unigration tests”)
  • 28. Client-side testing The new model – SharePoint-hosted Apps  Unit testing JavaScript  Faking the _api  Shallow integration (“unigration”) tests  Surely this is the Java logo?
  • 29. Options for client-side JavaScript testing Ad-hoc tests (e.g. console logging)  QUnit (qunitjs.com)    Jasmine   TDD style BDD style Mocha BDD or TDD style  PYO assertion library   UI tests (e.g. Selenium, VS UI tests)
  • 30. Running tests Can run tests in a browser window  Chutzpah test runner  Command line and Visual Studio integration  Only supports Jasmine and Qunit   For Continuous Integration use PhantomJS Headless browser  Chrome browser engine (WebKit)  Phantomjs.org   Use a cloud test service for “cross-browser test”  Includes device browsers
  • 32. Tips for Testing JavaScript Keep JavaScript modular in files, not scattered amongst HTML  To be able to Unit Test you need units  In JavaScript the unit of code encapsulation is the function  Very difficult to test an anonymous function  Very difficult to test a hidden function – may need to compromise encapsulation to make testable  Isolate tests from mark-up to avoid fragility 
  • 33. The ATDD Cycle User Story Write Acceptance Tests Acceptance Tests Pass Demo to PO QA write test refacto r pass
  • 34. How does ATDD work? Similar to BDD  A DSL for business users to define automated acceptance tests  Tooling such as Fitnesse, SpecFlow  Developer creates generic test fixtures  Can write tests first to drive development (outer loop – inner loop is TDD)  Gives test team something to do 
  • 35. How do we do acceptance tests?      End-to-end testing No requirement for tests to be fast (within reason) Tools like SpecFlow can be used to define tests (but is it worth it?) More likely a QA professional will manually build automated QA tests Tools:   Selenium WebDriver Visual Studio UI tests
  • 36. End-to-end Testing        Best suited for acceptance tests Drives application through the UI Selenium WebDriver, Watin, Visual Studio Can target different browsers Fully tests DOM manipulation, JavaScript, interaction with back-end (i.e. SharePoint) These tests often written by a dedicated tester Can be used for TDD but only if they are fast enough
  • 37. Conclusions Test Driven Development continues to gain traction in the development community as a whole and brings many benefits  SharePoint challenges us to find new ways of testing server-side code  The SharePoint 2013 App model brings with it a new world of client-side testing  Good news: client-side code is easier to test than server-side SharePoint code  Some end-to-end testing will be necessary particularly for acceptance tests 
  • 38. Recommended Reading: “The Art of Unit Testing”, Roy Osherove  www.extremeprogramming.org  “Clean Code – A Handbook of Agile Software Craftsmanship”, Robert C Martin  Lean-Agile Acceptance Test-Driven Development, Ken Pugh 
  • 39. Contact me: Blog: www.spdoctor.net  Twitter: @spdoctor  Sharepoint.stackexchange.com (moderator)  Email: BillA@flosim.com 