SlideShare a Scribd company logo
1 of 23
Download to read offline
Test Driven Development
on Force.com projects
Myths and Truths
March 10, 2016
Aldo Fernandez
Technical Architect
@aldoforce
Safe Harbor
Safe harbor statement under the Private Securities Litigation Reform Act of 1995: This presentation may contain forward-looking statements that involve
risks, uncertainties, and assumptions. If any such uncertainties materialize or if any of the assumptions proves incorrect, the results of salesforce.com,
inc. could differ materially from the results expressed or implied by the forward-looking statements we make. All statements other than statements of
historical fact could be deemed forward-looking, including any projections of subscriber growth, earnings, revenues, or other financial items and any
statements regarding strategies or plans of management for future operations, statements of belief, any statements concerning new, planned, or
upgraded services or technology developments and customer contracts or use of our services.
The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for our
service, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth, interruptions or delays in
our Web hosting, breach of our security measures, risks associated with possible mergers and acquisitions, the immature market in which we operate,
our relatively limited operating history, our ability to expand, retain, and motivate our employees and manage our growth, new releases of our service and
successful customer deployment, our limited history reselling non-salesforce.com products, and utilization and selling to larger enterprise customers.
Further information on potential factors that could affect the financial results of salesforce.com, inc. is included in our annual report on Form 10-K for the
most recent fiscal quarter ended July 31, 2011. This document and others are available on the SEC Filings section of the Investor Information section of
our Web site.
Any unreleased services or features referenced in this or other press releases or public statements are not currently available and may not be delivered
on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently available.
Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements.
Agenda
▪ What is TDD?
▪ TDD Process
▪ An Apex TDD Example
▪ Benefits
▪ Challenges
What is TDD? (I)
▪ …but first, what IS NOT TDD:
▪ TDD is not BDD (Behavior Driven Development)
▪ BDD: specs define tests, and then test defines code implementation
▪ BDD in Apex: Specs -> Test class -> class
▪ Cucumber (cucumber.io) based projects (Pickle, Pepino, …) which runs
acceptance tests defined in Gherkin
▪ …so, what IS TDD?
What is TDD? (II)
▪ It refers to a style of programming where three activities are tightly
interwoven:
▪ Coding
▪ Testing (in the form of unit tests)
▪ Design (in the form of refactoring)
What is TDD? (III)
“TDD is a software development
approach where tests are written
before the functional code”
“TDD is a technique of using
automated unit tests to drive the
design of software and force
decoupling of dependencies”
The TDD process
1. Write a test
2. Run all tests (the new should fail)
3. Write some code
4. Run tests
5. If tests passes, refactor
6. Repeat step 1
Unit Tests vs Integration Tests
▪ Unit Test
▪ Verify that a relatively small piece of
code is doing what is intended to do
▪ Narrow in scope
▪ Easy to write and execute
▪ Test useful for the developer
▪ No dependencies on external
components
▪ External components are mocked or
stubbed out
▪ Test internal consistency
▪ Integration Tests
▪ Verify that different pieces of the
system works correctly together.
▪ Covers whole business
requirements/features
▪ Require more resources to complete
▪ Test useful for business
▪ Dependencies are required because
the holistic approch.
▪ Test consistency between
components
An Apex TDD example (I)
▪ Aldo’s Algebra (don’t google… it’s just a trivial example!)
▪ Given 2 integer numbers (a, b) the sum operation will be a + b
▪ if one of the numbers is null, treat it as zero
▪ examples
▪ AA.sum(2, 3) = 5
▪ AA.sum(2, null) = 2
▪ AA.sum(null, null) = 0
An Apex TDD example (II)
An Apex TDD example (III)
An Apex TDD example (IV)
Repeat the process until
complete the spec
…but what if I have dependencies
on other classes/components?
An Apex TDD example (V)
AlgebraController
<<class>>
AlgebraServices
<<class>>
Algebra
<<page>>
An Apex TDD example (VI)
Dependency Injection
An Apex TDD example (VII)
An Apex TDD example (VIII)
Benefits
▪ Forces good architecture design
▪ Reduce time of bug hunting
▪ Creates a detailed specification
▪ Write shorter and less complex code
▪ Fewer system.debug() statements ;-)
▪ Instant feedback on broken code
▪ Code coverage on steroids (goodbye less than 75%)
▪ Enforce KISS and YAGNI
▪ Tests run faster
▪ Mocking around SOQL and DML to avoid declarative changes failures o/
Challenges
▪ Learning curve
▪ Cost of TDD vs Project Budget
▪ ROI with TDD
▪ Advanced concepts
▪ Dependency Injection
▪ Mocking
▪ Cultural issues
▪ Handling business requirements changes
Resources + Kudos
▪ Test Driven Development Method in Software Development Process. Denis Duka, Lovre
Hribar 2010
▪ Test Driven Development in Apex by Chris Aldridge (@caldrig3)
▪ Cucumber (cucumber.io)
▪ Pickle, a lightweight Cucumber implementation for Salesforce.com, github.com/lpoulain/pickle
▪ Pepino, BDD framework for Apex. github.com/pbattisson/pepino
▪ Unit Testing, Apex Enterprise Patterns and ApexMock, Andrew Fawcett (@andyinthecloud)
▪ Writing true unit tests using dependency injection mocking apex, Alex Tennant (@adtennant)
▪ ApexMocks: How Does It Work? Jesse Altman (@jessealtman)
▪ Inversion of Control Containers and the Dependency Injection Pattern. Martin Fowler, 2004
▪ Demo Code repo: https://github.com/aldoforce/uysdug_tdd_demo
Thank You!
Test Driven Development on
Force.com projects
Myths and Truths
Uruguay Salesforce Developer Group
March 10, 2016
#UYSDUG
Aldo Fernandez
Technical Architect
@aldoforce
#uysdug
#tdd
#dependencyInjection
#apex
#testing

More Related Content

What's hot

BDD em Testes de Serviço
BDD em Testes de ServiçoBDD em Testes de Serviço
BDD em Testes de ServiçoRafael Lima
 
Especificação de Requisitos de Software
Especificação de Requisitos de SoftwareEspecificação de Requisitos de Software
Especificação de Requisitos de SoftwareRalph Rassweiler
 
Git e Github para Iniciantes
Git e Github para IniciantesGit e Github para Iniciantes
Git e Github para IniciantesLoiane Groner
 
Elevando sua análise de métricas para o próximo nível
Elevando sua análise de métricas para o próximo nívelElevando sua análise de métricas para o próximo nível
Elevando sua análise de métricas para o próximo nívelJoão Grabosque
 
Como descrever cenários de teste utilizando Gherkin de forma correta
Como descrever cenários de teste utilizando Gherkin de forma corretaComo descrever cenários de teste utilizando Gherkin de forma correta
Como descrever cenários de teste utilizando Gherkin de forma corretaTesting Dojo Uai
 
Introduction to Bdd and cucumber
Introduction to Bdd and cucumberIntroduction to Bdd and cucumber
Introduction to Bdd and cucumberNibu Baby
 
What Is Cucumber?
What Is Cucumber?What Is Cucumber?
What Is Cucumber?QATestLab
 
Diagrama de Estados
Diagrama de EstadosDiagrama de Estados
Diagrama de EstadosMaikynata
 
Verificação e validação de software
Verificação e validação de softwareVerificação e validação de software
Verificação e validação de softwareLeonardo Melo Santos
 
Teste de Software Introdução à Qualidade
Teste de Software Introdução à Qualidade Teste de Software Introdução à Qualidade
Teste de Software Introdução à Qualidade Camilo Ribeiro
 
Acceptance Test Driven Development
Acceptance Test Driven DevelopmentAcceptance Test Driven Development
Acceptance Test Driven DevelopmentMike Douglas
 
Insprint automation, build the culture
Insprint automation, build the cultureInsprint automation, build the culture
Insprint automation, build the cultureShekharRamphal
 
Engenharia de Requisitos
Engenharia de RequisitosEngenharia de Requisitos
Engenharia de RequisitosCloves da Rocha
 
Cucumber presentation
Cucumber presentationCucumber presentation
Cucumber presentationAkhila B
 

What's hot (20)

Metricas ageis
Metricas ageisMetricas ageis
Metricas ageis
 
BDD em Testes de Serviço
BDD em Testes de ServiçoBDD em Testes de Serviço
BDD em Testes de Serviço
 
Especificação de Requisitos de Software
Especificação de Requisitos de SoftwareEspecificação de Requisitos de Software
Especificação de Requisitos de Software
 
Git e Github para Iniciantes
Git e Github para IniciantesGit e Github para Iniciantes
Git e Github para Iniciantes
 
Elevando sua análise de métricas para o próximo nível
Elevando sua análise de métricas para o próximo nívelElevando sua análise de métricas para o próximo nível
Elevando sua análise de métricas para o próximo nível
 
Modelagem com historias bem além dos requisitos
Modelagem com historias bem além dos requisitosModelagem com historias bem além dos requisitos
Modelagem com historias bem além dos requisitos
 
Como descrever cenários de teste utilizando Gherkin de forma correta
Como descrever cenários de teste utilizando Gherkin de forma corretaComo descrever cenários de teste utilizando Gherkin de forma correta
Como descrever cenários de teste utilizando Gherkin de forma correta
 
FDD
FDDFDD
FDD
 
Introduction to Bdd and cucumber
Introduction to Bdd and cucumberIntroduction to Bdd and cucumber
Introduction to Bdd and cucumber
 
What Is Cucumber?
What Is Cucumber?What Is Cucumber?
What Is Cucumber?
 
Diagrama de Estados
Diagrama de EstadosDiagrama de Estados
Diagrama de Estados
 
Verificação e validação de software
Verificação e validação de softwareVerificação e validação de software
Verificação e validação de software
 
Teste de Software Introdução à Qualidade
Teste de Software Introdução à Qualidade Teste de Software Introdução à Qualidade
Teste de Software Introdução à Qualidade
 
Acceptance Test Driven Development
Acceptance Test Driven DevelopmentAcceptance Test Driven Development
Acceptance Test Driven Development
 
Insprint automation, build the culture
Insprint automation, build the cultureInsprint automation, build the culture
Insprint automation, build the culture
 
Gherkin /BDD intro
Gherkin /BDD introGherkin /BDD intro
Gherkin /BDD intro
 
Cucumber BDD
Cucumber BDDCucumber BDD
Cucumber BDD
 
Engenharia de Requisitos
Engenharia de RequisitosEngenharia de Requisitos
Engenharia de Requisitos
 
BDD & Cucumber
BDD & CucumberBDD & Cucumber
BDD & Cucumber
 
Cucumber presentation
Cucumber presentationCucumber presentation
Cucumber presentation
 

Viewers also liked

Behaviour Driven Development (BDD) With Apex on Force.com
Behaviour Driven Development (BDD) With Apex on Force.comBehaviour Driven Development (BDD) With Apex on Force.com
Behaviour Driven Development (BDD) With Apex on Force.comSalesforce Developers
 
The Modern Salesforce Development Workflow with Visual Studio Code
The Modern Salesforce Development Workflow with Visual Studio CodeThe Modern Salesforce Development Workflow with Visual Studio Code
The Modern Salesforce Development Workflow with Visual Studio CodeSalesforce Developers
 
App Cloud and The Internet of Things
App Cloud and The Internet of ThingsApp Cloud and The Internet of Things
App Cloud and The Internet of ThingsSalesforce Developers
 

Viewers also liked (6)

Behaviour Driven Development (BDD) With Apex on Force.com
Behaviour Driven Development (BDD) With Apex on Force.comBehaviour Driven Development (BDD) With Apex on Force.com
Behaviour Driven Development (BDD) With Apex on Force.com
 
The Modern Salesforce Development Workflow with Visual Studio Code
The Modern Salesforce Development Workflow with Visual Studio CodeThe Modern Salesforce Development Workflow with Visual Studio Code
The Modern Salesforce Development Workflow with Visual Studio Code
 
App Cloud and The Internet of Things
App Cloud and The Internet of ThingsApp Cloud and The Internet of Things
App Cloud and The Internet of Things
 
LEARNING CURVE
LEARNING CURVELEARNING CURVE
LEARNING CURVE
 
Selenium at Salesforce Scale
Selenium at Salesforce ScaleSelenium at Salesforce Scale
Selenium at Salesforce Scale
 
Best Practices for Testing in salesforce.com
Best Practices for Testing in salesforce.comBest Practices for Testing in salesforce.com
Best Practices for Testing in salesforce.com
 

Similar to Test Driven Development (TDD) on Force.com projects

Manage Development in Your Org with Salesforce Governance Framework
Manage Development in Your Org with Salesforce Governance FrameworkManage Development in Your Org with Salesforce Governance Framework
Manage Development in Your Org with Salesforce Governance FrameworkSalesforce Developers
 
Best Practices for Team Development in a Single Org
Best Practices for Team Development in a Single OrgBest Practices for Team Development in a Single Org
Best Practices for Team Development in a Single OrgSalesforce Developers
 
Designing custom REST and SOAP interfaces on Force.com
Designing custom REST and SOAP interfaces on Force.comDesigning custom REST and SOAP interfaces on Force.com
Designing custom REST and SOAP interfaces on Force.comSteven Herod
 
Continuous Integration - Software development lifecycle for Force.com projects
Continuous Integration - Software development lifecycle for Force.com projectsContinuous Integration - Software development lifecycle for Force.com projects
Continuous Integration - Software development lifecycle for Force.com projectsAldo Fernandez
 
Building Command-line Tools with the Tooling API
Building Command-line Tools with the Tooling APIBuilding Command-line Tools with the Tooling API
Building Command-line Tools with the Tooling APIJeff Douglas
 
Building Complex Traversing & Branching Apps Using Visual Workflows and Apex
Building Complex Traversing & Branching Apps Using Visual Workflows and ApexBuilding Complex Traversing & Branching Apps Using Visual Workflows and Apex
Building Complex Traversing & Branching Apps Using Visual Workflows and ApexSalesforce Developers
 
Designing Custom REST and SOAP Interfaces on Force.com
Designing Custom REST and SOAP Interfaces on Force.comDesigning Custom REST and SOAP Interfaces on Force.com
Designing Custom REST and SOAP Interfaces on Force.comSalesforce Developers
 
Intro to Salesforce Lightning for Admins
Intro to Salesforce Lightning for Admins Intro to Salesforce Lightning for Admins
Intro to Salesforce Lightning for Admins Desynit
 
TDX19 - Accelerate DevOps with GitLab and Salesforce
TDX19 - Accelerate DevOps with GitLab and SalesforceTDX19 - Accelerate DevOps with GitLab and Salesforce
TDX19 - Accelerate DevOps with GitLab and SalesforceDoug Ayers
 
Bridging the Gap between Clicks & Code
Bridging the Gap between Clicks & CodeBridging the Gap between Clicks & Code
Bridging the Gap between Clicks & CodeSalesforce Admins
 
Elevate Madrid Essentials - Advance Track
Elevate Madrid Essentials - Advance TrackElevate Madrid Essentials - Advance Track
Elevate Madrid Essentials - Advance TrackCarolEnLaNube
 
Lightning Developer Experience, Eclipse IDE Evolved
Lightning Developer Experience, Eclipse IDE EvolvedLightning Developer Experience, Eclipse IDE Evolved
Lightning Developer Experience, Eclipse IDE EvolvedSalesforce Developers
 
Shorten Your Development Time with an Extensible Design for Apex
Shorten Your Development Time with an Extensible Design for ApexShorten Your Development Time with an Extensible Design for Apex
Shorten Your Development Time with an Extensible Design for ApexSalesforce Developers
 
Enterprise-grade UI with open source Lightning Web Components
Enterprise-grade UI with open source Lightning Web ComponentsEnterprise-grade UI with open source Lightning Web Components
Enterprise-grade UI with open source Lightning Web ComponentsSalesforce Developers
 

Similar to Test Driven Development (TDD) on Force.com projects (20)

Manage Development in Your Org with Salesforce Governance Framework
Manage Development in Your Org with Salesforce Governance FrameworkManage Development in Your Org with Salesforce Governance Framework
Manage Development in Your Org with Salesforce Governance Framework
 
Best Practices for Team Development in a Single Org
Best Practices for Team Development in a Single OrgBest Practices for Team Development in a Single Org
Best Practices for Team Development in a Single Org
 
Designing custom REST and SOAP interfaces on Force.com
Designing custom REST and SOAP interfaces on Force.comDesigning custom REST and SOAP interfaces on Force.com
Designing custom REST and SOAP interfaces on Force.com
 
Continuous Integration - Software development lifecycle for Force.com projects
Continuous Integration - Software development lifecycle for Force.com projectsContinuous Integration - Software development lifecycle for Force.com projects
Continuous Integration - Software development lifecycle for Force.com projects
 
API Design for Your Packaged App
API Design for Your Packaged AppAPI Design for Your Packaged App
API Design for Your Packaged App
 
Building Command-line Tools with the Tooling API
Building Command-line Tools with the Tooling APIBuilding Command-line Tools with the Tooling API
Building Command-line Tools with the Tooling API
 
Development Best Practices
Development Best PracticesDevelopment Best Practices
Development Best Practices
 
Building Complex Traversing & Branching Apps Using Visual Workflows and Apex
Building Complex Traversing & Branching Apps Using Visual Workflows and ApexBuilding Complex Traversing & Branching Apps Using Visual Workflows and Apex
Building Complex Traversing & Branching Apps Using Visual Workflows and Apex
 
Designing Custom REST and SOAP Interfaces on Force.com
Designing Custom REST and SOAP Interfaces on Force.comDesigning Custom REST and SOAP Interfaces on Force.com
Designing Custom REST and SOAP Interfaces on Force.com
 
API Design for Your Packaged App
API Design for Your Packaged AppAPI Design for Your Packaged App
API Design for Your Packaged App
 
Force.com Friday : Intro to Apex
Force.com Friday : Intro to Apex Force.com Friday : Intro to Apex
Force.com Friday : Intro to Apex
 
Introduction to Apex Triggers
Introduction to Apex TriggersIntroduction to Apex Triggers
Introduction to Apex Triggers
 
Intro to Salesforce Lightning for Admins
Intro to Salesforce Lightning for Admins Intro to Salesforce Lightning for Admins
Intro to Salesforce Lightning for Admins
 
TDX19 - Accelerate DevOps with GitLab and Salesforce
TDX19 - Accelerate DevOps with GitLab and SalesforceTDX19 - Accelerate DevOps with GitLab and Salesforce
TDX19 - Accelerate DevOps with GitLab and Salesforce
 
Bridging the Gap between Clicks & Code
Bridging the Gap between Clicks & CodeBridging the Gap between Clicks & Code
Bridging the Gap between Clicks & Code
 
Elevate Madrid Essentials - Advance Track
Elevate Madrid Essentials - Advance TrackElevate Madrid Essentials - Advance Track
Elevate Madrid Essentials - Advance Track
 
Lightning Developer Experience, Eclipse IDE Evolved
Lightning Developer Experience, Eclipse IDE EvolvedLightning Developer Experience, Eclipse IDE Evolved
Lightning Developer Experience, Eclipse IDE Evolved
 
Get Started with Salesforce DX!
Get Started with Salesforce DX!Get Started with Salesforce DX!
Get Started with Salesforce DX!
 
Shorten Your Development Time with an Extensible Design for Apex
Shorten Your Development Time with an Extensible Design for ApexShorten Your Development Time with an Extensible Design for Apex
Shorten Your Development Time with an Extensible Design for Apex
 
Enterprise-grade UI with open source Lightning Web Components
Enterprise-grade UI with open source Lightning Web ComponentsEnterprise-grade UI with open source Lightning Web Components
Enterprise-grade UI with open source Lightning Web Components
 

More from Aldo Fernandez

November meetup - Hello Winter'16
November meetup - Hello Winter'16November meetup - Hello Winter'16
November meetup - Hello Winter'16Aldo Fernandez
 
06 august meetup - enterprise integration architecture
06   august meetup - enterprise integration architecture06   august meetup - enterprise integration architecture
06 august meetup - enterprise integration architectureAldo Fernandez
 
Procesando Salesforce Outbound Messages con PHP en Heroku
Procesando Salesforce Outbound Messages con PHP en HerokuProcesando Salesforce Outbound Messages con PHP en Heroku
Procesando Salesforce Outbound Messages con PHP en HerokuAldo Fernandez
 
04 june meetup - An overview of OAuth2 on Force.com projects
04   june meetup - An overview of OAuth2 on Force.com projects04   june meetup - An overview of OAuth2 on Force.com projects
04 june meetup - An overview of OAuth2 on Force.com projectsAldo Fernandez
 
Processing outbound messages with Node.js
Processing outbound messages with Node.jsProcessing outbound messages with Node.js
Processing outbound messages with Node.jsAldo Fernandez
 
Salesforce1 dev week UYSDUG 2014 - the force canvas spark
Salesforce1 dev week UYSDUG 2014 - the force canvas sparkSalesforce1 dev week UYSDUG 2014 - the force canvas spark
Salesforce1 dev week UYSDUG 2014 - the force canvas sparkAldo Fernandez
 
Salesforce1 lightning dev week UYSDUG 2015 - Lightning Connect
Salesforce1 lightning dev week UYSDUG 2015 - Lightning ConnectSalesforce1 lightning dev week UYSDUG 2015 - Lightning Connect
Salesforce1 lightning dev week UYSDUG 2015 - Lightning ConnectAldo Fernandez
 
Salesforce mobile dev weel UYSDUG 2013 - Enabling restful services for mobile...
Salesforce mobile dev weel UYSDUG 2013 - Enabling restful services for mobile...Salesforce mobile dev weel UYSDUG 2013 - Enabling restful services for mobile...
Salesforce mobile dev weel UYSDUG 2013 - Enabling restful services for mobile...Aldo Fernandez
 

More from Aldo Fernandez (8)

November meetup - Hello Winter'16
November meetup - Hello Winter'16November meetup - Hello Winter'16
November meetup - Hello Winter'16
 
06 august meetup - enterprise integration architecture
06   august meetup - enterprise integration architecture06   august meetup - enterprise integration architecture
06 august meetup - enterprise integration architecture
 
Procesando Salesforce Outbound Messages con PHP en Heroku
Procesando Salesforce Outbound Messages con PHP en HerokuProcesando Salesforce Outbound Messages con PHP en Heroku
Procesando Salesforce Outbound Messages con PHP en Heroku
 
04 june meetup - An overview of OAuth2 on Force.com projects
04   june meetup - An overview of OAuth2 on Force.com projects04   june meetup - An overview of OAuth2 on Force.com projects
04 june meetup - An overview of OAuth2 on Force.com projects
 
Processing outbound messages with Node.js
Processing outbound messages with Node.jsProcessing outbound messages with Node.js
Processing outbound messages with Node.js
 
Salesforce1 dev week UYSDUG 2014 - the force canvas spark
Salesforce1 dev week UYSDUG 2014 - the force canvas sparkSalesforce1 dev week UYSDUG 2014 - the force canvas spark
Salesforce1 dev week UYSDUG 2014 - the force canvas spark
 
Salesforce1 lightning dev week UYSDUG 2015 - Lightning Connect
Salesforce1 lightning dev week UYSDUG 2015 - Lightning ConnectSalesforce1 lightning dev week UYSDUG 2015 - Lightning Connect
Salesforce1 lightning dev week UYSDUG 2015 - Lightning Connect
 
Salesforce mobile dev weel UYSDUG 2013 - Enabling restful services for mobile...
Salesforce mobile dev weel UYSDUG 2013 - Enabling restful services for mobile...Salesforce mobile dev weel UYSDUG 2013 - Enabling restful services for mobile...
Salesforce mobile dev weel UYSDUG 2013 - Enabling restful services for mobile...
 

Recently uploaded

(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 

Recently uploaded (20)

(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 

Test Driven Development (TDD) on Force.com projects

  • 1. Test Driven Development on Force.com projects Myths and Truths March 10, 2016
  • 3. Safe Harbor Safe harbor statement under the Private Securities Litigation Reform Act of 1995: This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties materialize or if any of the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or implied by the forward-looking statements we make. All statements other than statements of historical fact could be deemed forward-looking, including any projections of subscriber growth, earnings, revenues, or other financial items and any statements regarding strategies or plans of management for future operations, statements of belief, any statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of our services. The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for our service, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth, interruptions or delays in our Web hosting, breach of our security measures, risks associated with possible mergers and acquisitions, the immature market in which we operate, our relatively limited operating history, our ability to expand, retain, and motivate our employees and manage our growth, new releases of our service and successful customer deployment, our limited history reselling non-salesforce.com products, and utilization and selling to larger enterprise customers. Further information on potential factors that could affect the financial results of salesforce.com, inc. is included in our annual report on Form 10-K for the most recent fiscal quarter ended July 31, 2011. This document and others are available on the SEC Filings section of the Investor Information section of our Web site. Any unreleased services or features referenced in this or other press releases or public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements.
  • 4. Agenda ▪ What is TDD? ▪ TDD Process ▪ An Apex TDD Example ▪ Benefits ▪ Challenges
  • 5. What is TDD? (I) ▪ …but first, what IS NOT TDD: ▪ TDD is not BDD (Behavior Driven Development) ▪ BDD: specs define tests, and then test defines code implementation ▪ BDD in Apex: Specs -> Test class -> class ▪ Cucumber (cucumber.io) based projects (Pickle, Pepino, …) which runs acceptance tests defined in Gherkin ▪ …so, what IS TDD?
  • 6. What is TDD? (II) ▪ It refers to a style of programming where three activities are tightly interwoven: ▪ Coding ▪ Testing (in the form of unit tests) ▪ Design (in the form of refactoring)
  • 7. What is TDD? (III) “TDD is a software development approach where tests are written before the functional code” “TDD is a technique of using automated unit tests to drive the design of software and force decoupling of dependencies”
  • 8. The TDD process 1. Write a test 2. Run all tests (the new should fail) 3. Write some code 4. Run tests 5. If tests passes, refactor 6. Repeat step 1
  • 9. Unit Tests vs Integration Tests ▪ Unit Test ▪ Verify that a relatively small piece of code is doing what is intended to do ▪ Narrow in scope ▪ Easy to write and execute ▪ Test useful for the developer ▪ No dependencies on external components ▪ External components are mocked or stubbed out ▪ Test internal consistency ▪ Integration Tests ▪ Verify that different pieces of the system works correctly together. ▪ Covers whole business requirements/features ▪ Require more resources to complete ▪ Test useful for business ▪ Dependencies are required because the holistic approch. ▪ Test consistency between components
  • 10. An Apex TDD example (I) ▪ Aldo’s Algebra (don’t google… it’s just a trivial example!) ▪ Given 2 integer numbers (a, b) the sum operation will be a + b ▪ if one of the numbers is null, treat it as zero ▪ examples ▪ AA.sum(2, 3) = 5 ▪ AA.sum(2, null) = 2 ▪ AA.sum(null, null) = 0
  • 11. An Apex TDD example (II)
  • 12. An Apex TDD example (III)
  • 13. An Apex TDD example (IV) Repeat the process until complete the spec
  • 14. …but what if I have dependencies on other classes/components?
  • 15. An Apex TDD example (V) AlgebraController <<class>> AlgebraServices <<class>> Algebra <<page>>
  • 16. An Apex TDD example (VI)
  • 18. An Apex TDD example (VII)
  • 19. An Apex TDD example (VIII)
  • 20. Benefits ▪ Forces good architecture design ▪ Reduce time of bug hunting ▪ Creates a detailed specification ▪ Write shorter and less complex code ▪ Fewer system.debug() statements ;-) ▪ Instant feedback on broken code ▪ Code coverage on steroids (goodbye less than 75%) ▪ Enforce KISS and YAGNI ▪ Tests run faster ▪ Mocking around SOQL and DML to avoid declarative changes failures o/
  • 21. Challenges ▪ Learning curve ▪ Cost of TDD vs Project Budget ▪ ROI with TDD ▪ Advanced concepts ▪ Dependency Injection ▪ Mocking ▪ Cultural issues ▪ Handling business requirements changes
  • 22. Resources + Kudos ▪ Test Driven Development Method in Software Development Process. Denis Duka, Lovre Hribar 2010 ▪ Test Driven Development in Apex by Chris Aldridge (@caldrig3) ▪ Cucumber (cucumber.io) ▪ Pickle, a lightweight Cucumber implementation for Salesforce.com, github.com/lpoulain/pickle ▪ Pepino, BDD framework for Apex. github.com/pbattisson/pepino ▪ Unit Testing, Apex Enterprise Patterns and ApexMock, Andrew Fawcett (@andyinthecloud) ▪ Writing true unit tests using dependency injection mocking apex, Alex Tennant (@adtennant) ▪ ApexMocks: How Does It Work? Jesse Altman (@jessealtman) ▪ Inversion of Control Containers and the Dependency Injection Pattern. Martin Fowler, 2004 ▪ Demo Code repo: https://github.com/aldoforce/uysdug_tdd_demo
  • 23. Thank You! Test Driven Development on Force.com projects Myths and Truths Uruguay Salesforce Developer Group March 10, 2016 #UYSDUG Aldo Fernandez Technical Architect @aldoforce #uysdug #tdd #dependencyInjection #apex #testing