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

Implement BDD with Cucumber and SpecFlow
Implement BDD with Cucumber and SpecFlowImplement BDD with Cucumber and SpecFlow
Implement BDD with Cucumber and SpecFlowTechWell
 
Anypoint platform architecture and components
Anypoint platform architecture and componentsAnypoint platform architecture and components
Anypoint platform architecture and componentsD.Rajesh Kumar
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven DevelopmentDhaval Dalal
 
How to Build a Proof of Concept
How to Build a Proof of Concept How to Build a Proof of Concept
How to Build a Proof of Concept Michael Hamilton
 
The complete guide to BDD + Cucumber Best Practices and Anti-Patterns.
The complete guide to BDD + Cucumber Best Practices and Anti-Patterns.The complete guide to BDD + Cucumber Best Practices and Anti-Patterns.
The complete guide to BDD + Cucumber Best Practices and Anti-Patterns.Test Evolve
 
Return of the monolith
Return of the monolith Return of the monolith
Return of the monolith Alper Hankendi
 
Micro Frontends: Rompiendo el monolito en las aplicaciones Web
Micro Frontends: Rompiendo el monolito en las aplicaciones WebMicro Frontends: Rompiendo el monolito en las aplicaciones Web
Micro Frontends: Rompiendo el monolito en las aplicaciones WebBelatrix Software
 
2021 JCconf TW Going Reactive with Quarkus Kotlin & Arrow-KT
2021 JCconf TW Going Reactive with Quarkus Kotlin & Arrow-KT2021 JCconf TW Going Reactive with Quarkus Kotlin & Arrow-KT
2021 JCconf TW Going Reactive with Quarkus Kotlin & Arrow-KTHung-Ming Chang
 
Cyclomatic and cognitive complexity
Cyclomatic and cognitive complexityCyclomatic and cognitive complexity
Cyclomatic and cognitive complexityHeemeng Foo
 
Performance testing : An Overview
Performance testing : An OverviewPerformance testing : An Overview
Performance testing : An Overviewsharadkjain
 
Oracle Forms to APEX conversion tool
Oracle Forms to APEX conversion toolOracle Forms to APEX conversion tool
Oracle Forms to APEX conversion toolScott Wesley
 
TOSCA and OpenTOSCA: TOSCA Introduction and OpenTOSCA Ecosystem Overview
TOSCA and OpenTOSCA: TOSCA Introduction and OpenTOSCA Ecosystem OverviewTOSCA and OpenTOSCA: TOSCA Introduction and OpenTOSCA Ecosystem Overview
TOSCA and OpenTOSCA: TOSCA Introduction and OpenTOSCA Ecosystem OverviewOpenTOSCA
 
Getting Started With Apex REST Services
Getting Started With Apex REST ServicesGetting Started With Apex REST Services
Getting Started With Apex REST ServicesSalesforce Developers
 
Microservices Architecture - Cloud Native Apps
Microservices Architecture - Cloud Native AppsMicroservices Architecture - Cloud Native Apps
Microservices Architecture - Cloud Native AppsAraf Karsh Hamid
 
LWC Episode 3- Component Communication and Aura Interoperability
LWC Episode 3- Component Communication and Aura InteroperabilityLWC Episode 3- Component Communication and Aura Interoperability
LWC Episode 3- Component Communication and Aura InteroperabilitySalesforce Developers
 
OpenID Connect and Single Sign-On for Beginners
OpenID Connect and Single Sign-On for BeginnersOpenID Connect and Single Sign-On for Beginners
OpenID Connect and Single Sign-On for BeginnersSalesforce Developers
 
Designing Autonomous Teams and Services
Designing Autonomous Teams and ServicesDesigning Autonomous Teams and Services
Designing Autonomous Teams and ServicesNick Tune
 
Lightning Data Service: Eliminate Your Need to Load Records Through Controllers
Lightning Data Service: Eliminate Your Need to Load Records Through ControllersLightning Data Service: Eliminate Your Need to Load Records Through Controllers
Lightning Data Service: Eliminate Your Need to Load Records Through ControllersSalesforce Developers
 
How to Build a Platform Team
How to Build a Platform TeamHow to Build a Platform Team
How to Build a Platform TeamVMware Tanzu
 

What's hot (20)

Implement BDD with Cucumber and SpecFlow
Implement BDD with Cucumber and SpecFlowImplement BDD with Cucumber and SpecFlow
Implement BDD with Cucumber and SpecFlow
 
Anypoint platform architecture and components
Anypoint platform architecture and componentsAnypoint platform architecture and components
Anypoint platform architecture and components
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
How to Build a Proof of Concept
How to Build a Proof of Concept How to Build a Proof of Concept
How to Build a Proof of Concept
 
The complete guide to BDD + Cucumber Best Practices and Anti-Patterns.
The complete guide to BDD + Cucumber Best Practices and Anti-Patterns.The complete guide to BDD + Cucumber Best Practices and Anti-Patterns.
The complete guide to BDD + Cucumber Best Practices and Anti-Patterns.
 
Return of the monolith
Return of the monolith Return of the monolith
Return of the monolith
 
Micro Frontends: Rompiendo el monolito en las aplicaciones Web
Micro Frontends: Rompiendo el monolito en las aplicaciones WebMicro Frontends: Rompiendo el monolito en las aplicaciones Web
Micro Frontends: Rompiendo el monolito en las aplicaciones Web
 
2021 JCconf TW Going Reactive with Quarkus Kotlin & Arrow-KT
2021 JCconf TW Going Reactive with Quarkus Kotlin & Arrow-KT2021 JCconf TW Going Reactive with Quarkus Kotlin & Arrow-KT
2021 JCconf TW Going Reactive with Quarkus Kotlin & Arrow-KT
 
Teste de Mutação
Teste de MutaçãoTeste de Mutação
Teste de Mutação
 
Cyclomatic and cognitive complexity
Cyclomatic and cognitive complexityCyclomatic and cognitive complexity
Cyclomatic and cognitive complexity
 
Performance testing : An Overview
Performance testing : An OverviewPerformance testing : An Overview
Performance testing : An Overview
 
Oracle Forms to APEX conversion tool
Oracle Forms to APEX conversion toolOracle Forms to APEX conversion tool
Oracle Forms to APEX conversion tool
 
TOSCA and OpenTOSCA: TOSCA Introduction and OpenTOSCA Ecosystem Overview
TOSCA and OpenTOSCA: TOSCA Introduction and OpenTOSCA Ecosystem OverviewTOSCA and OpenTOSCA: TOSCA Introduction and OpenTOSCA Ecosystem Overview
TOSCA and OpenTOSCA: TOSCA Introduction and OpenTOSCA Ecosystem Overview
 
Getting Started With Apex REST Services
Getting Started With Apex REST ServicesGetting Started With Apex REST Services
Getting Started With Apex REST Services
 
Microservices Architecture - Cloud Native Apps
Microservices Architecture - Cloud Native AppsMicroservices Architecture - Cloud Native Apps
Microservices Architecture - Cloud Native Apps
 
LWC Episode 3- Component Communication and Aura Interoperability
LWC Episode 3- Component Communication and Aura InteroperabilityLWC Episode 3- Component Communication and Aura Interoperability
LWC Episode 3- Component Communication and Aura Interoperability
 
OpenID Connect and Single Sign-On for Beginners
OpenID Connect and Single Sign-On for BeginnersOpenID Connect and Single Sign-On for Beginners
OpenID Connect and Single Sign-On for Beginners
 
Designing Autonomous Teams and Services
Designing Autonomous Teams and ServicesDesigning Autonomous Teams and Services
Designing Autonomous Teams and Services
 
Lightning Data Service: Eliminate Your Need to Load Records Through Controllers
Lightning Data Service: Eliminate Your Need to Load Records Through ControllersLightning Data Service: Eliminate Your Need to Load Records Through Controllers
Lightning Data Service: Eliminate Your Need to Load Records Through Controllers
 
How to Build a Platform Team
How to Build a Platform TeamHow to Build a Platform Team
How to Build a Platform Team
 

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
 
Salesforce – Proven Platform Development with DevOps & Agile
Salesforce – Proven Platform Development with DevOps & AgileSalesforce – Proven Platform Development with DevOps & Agile
Salesforce – Proven Platform Development with DevOps & AgileSai Jithesh ☁️
 

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
 
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
 
Salesforce – Proven Platform Development with DevOps & Agile
Salesforce – Proven Platform Development with DevOps & AgileSalesforce – Proven Platform Development with DevOps & Agile
Salesforce – Proven Platform Development with DevOps & Agile
 

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

Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfJiananWang21
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxSCMS School of Architecture
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...soginsider
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptDineshKumar4165
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdfKamal Acharya
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxSCMS School of Architecture
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.Kamal Acharya
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdfKamal Acharya
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationBhangaleSonal
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayEpec Engineered Technologies
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Call Girls Mumbai
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Arindam Chakraborty, Ph.D., P.E. (CA, TX)
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaOmar Fathy
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadhamedmustafa094
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projectssmsksolar
 

Recently uploaded (20)

Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal load
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
 

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