SlideShare una empresa de Scribd logo
1 de 15
Testing
expect(subject).to
be_awesome
Why Test?
To prevent regression
Refactoring safety net
Posterity of intention
Doubles as documentation
To expose sub-optimal code design
“Proving your work”
Fixes are more expensive the later it is detected*
Cost of Defects
Stage Cost
Requirements Time to rewrite requirement
Coding Addtl. Hours for engineer
QA Addtl. Hours for engineer + PM + QA
User Acceptance Testing Addtl. Hours eng + PM + QA + customer
Production Addtl. Hours eng + support + PM +
customer + QA. Reputational loss. Fixing
production data.
10x more expensive if bug found in Production than in Requirements
The Delivery Pipeline Dream
Branch
merged
CI runs
tests
Tests pass
Deploys to
production
JIRA
updated
“Trust your test suite with your life”
In 2012 Github deployed 12,602 times. Busiest day saw 175 deploys.
What Makes a Good Test?
Testing the interface
Good enough coverage, but not burdensome
Considers edge cases
Clear, concise, comprehensive, correct
Verify that you’ve met the stated requirements
When Tests Go Bad
Brittleness (mocking too much, testing implementation, etc)
Unreliable (Full stack tests reliant on timing guesswork)
Sluggishness
Incomprehensible
Size of test suite*
The Testing Pyramid
What Should I Test?
What Should I Test?
Good rule of thumb: If you are manually setting up data (Rails console, other
REPL, etc) and testing a change you are making, this should be your test
Same requirements as what the US considers patentable: “clever or non-obvious”
Aim for 80% test coverage - Complete coverage is asymptotic
Regressions (“Fool me once...”)
Code to be refactored
Test Types
Unit (component)
Integration
Full stack (e.g. “browser”)
Functional tests (e.g. “controller” aka “black box”)
Manual Testing (QA)
Performance/Stress/Load
A/B
End to End
Unit Testing Demo
Lead.mobile - Context, it, Factory pattern, expectation matcher, running tests
Lead.determine_business_unit_id - code branches, build vs create, running context
Lead.import_addresses_from_identifier_field - decomposing, stubbing
Controller / Functional Testing Demo
LeadsController.new - before/after hooks, missing records, traits, ivar, type matchers,
multiple assertions
Full Stack (Browser) Test Demo
AuthenticationSpec - feature, Capybara definitions
Summary
Testing is not an action taken “after the fact” that is meant to check a box
Proper testing helps guide code structure
The extreme of this is TDD (Test Driven Development) where tests are written
(and fail) before the code is written that allows the tests to pass
Lower defect count
Generally results in smaller, focused methods
Being a better tester will make you a better developer
Thank You
Ben Simpson
thehoagie@gmail.com
@mrfrosti

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Karate - MoT Dallas 26-Oct-2017
Karate - MoT Dallas 26-Oct-2017Karate - MoT Dallas 26-Oct-2017
Karate - MoT Dallas 26-Oct-2017
 
RSpec and Rails
RSpec and RailsRSpec and Rails
RSpec and Rails
 
BDD for APIs
BDD for APIsBDD for APIs
BDD for APIs
 
A Deep Dive into the W3C WebDriver Specification
A Deep Dive into the W3C WebDriver SpecificationA Deep Dive into the W3C WebDriver Specification
A Deep Dive into the W3C WebDriver Specification
 
Salesforce asynchronous apex
Salesforce asynchronous apexSalesforce asynchronous apex
Salesforce asynchronous apex
 
RSpec: What, How and Why
RSpec: What, How and WhyRSpec: What, How and Why
RSpec: What, How and Why
 
Developing a Culture of Quality Code (Midwest PHP 2020)
Developing a Culture of Quality Code (Midwest PHP 2020)Developing a Culture of Quality Code (Midwest PHP 2020)
Developing a Culture of Quality Code (Midwest PHP 2020)
 
Automate right start from API
Automate right start from APIAutomate right start from API
Automate right start from API
 
Patterns of a "Good" Test Automation Framework, Locators & Data
Patterns of a "Good" Test Automation Framework, Locators & DataPatterns of a "Good" Test Automation Framework, Locators & Data
Patterns of a "Good" Test Automation Framework, Locators & Data
 
TDC São Paulo 2019 - Trilha DevTest - Karatê DSL - Automatizando testes de AP...
TDC São Paulo 2019 - Trilha DevTest - Karatê DSL - Automatizando testes de AP...TDC São Paulo 2019 - Trilha DevTest - Karatê DSL - Automatizando testes de AP...
TDC São Paulo 2019 - Trilha DevTest - Karatê DSL - Automatizando testes de AP...
 
Intro to front-end testing
Intro to front-end testingIntro to front-end testing
Intro to front-end testing
 
Интеграция решения по тестированию производительности в существующий фреймвор...
Интеграция решения по тестированию производительности в существующий фреймвор...Интеграция решения по тестированию производительности в существующий фреймвор...
Интеграция решения по тестированию производительности в существующий фреймвор...
 
TDD, BDD and mocks
TDD, BDD and mocksTDD, BDD and mocks
TDD, BDD and mocks
 
Apex 10 commandments df14
Apex 10 commandments df14Apex 10 commandments df14
Apex 10 commandments df14
 
Build Reliable Asynchronous Code with Queueable Apex
Build Reliable Asynchronous Code with Queueable ApexBuild Reliable Asynchronous Code with Queueable Apex
Build Reliable Asynchronous Code with Queueable Apex
 
Angular Unit Test
Angular Unit TestAngular Unit Test
Angular Unit Test
 
[FullStack NYC 2019] Effective Unit Tests for JavaScript
[FullStack NYC 2019] Effective Unit Tests for JavaScript[FullStack NYC 2019] Effective Unit Tests for JavaScript
[FullStack NYC 2019] Effective Unit Tests for JavaScript
 
Wax on, wax off
Wax on, wax offWax on, wax off
Wax on, wax off
 
Nikolai Boiko "NodeJS Refactoring: How to kill a Dragon and stay alive"
Nikolai Boiko "NodeJS Refactoring: How to kill a Dragon and stay alive"Nikolai Boiko "NodeJS Refactoring: How to kill a Dragon and stay alive"
Nikolai Boiko "NodeJS Refactoring: How to kill a Dragon and stay alive"
 
Vaugham Hong - Embedding JavaScript V8
Vaugham Hong - Embedding JavaScript V8Vaugham Hong - Embedding JavaScript V8
Vaugham Hong - Embedding JavaScript V8
 

Similar a Testing

Agile Testing Pasadena JUG Aug2009
Agile Testing Pasadena JUG Aug2009Agile Testing Pasadena JUG Aug2009
Agile Testing Pasadena JUG Aug2009
Grig Gheorghiu
 
Building Quality with Foundations of Mud
Building Quality with Foundations of MudBuilding Quality with Foundations of Mud
Building Quality with Foundations of Mud
seleniumconf
 
Cerberus_Presentation1
Cerberus_Presentation1Cerberus_Presentation1
Cerberus_Presentation1
CIVEL Benoit
 

Similar a Testing (20)

Software Quality and Test Strategies for Ruby and Rails Applications
Software Quality and Test Strategies for Ruby and Rails ApplicationsSoftware Quality and Test Strategies for Ruby and Rails Applications
Software Quality and Test Strategies for Ruby and Rails Applications
 
Automated Acceptance Tests & Tool choice
Automated Acceptance Tests & Tool choiceAutomated Acceptance Tests & Tool choice
Automated Acceptance Tests & Tool choice
 
Testing in a glance
Testing in a glanceTesting in a glance
Testing in a glance
 
Testing 101
Testing 101Testing 101
Testing 101
 
Behavior Driven Development by Example
Behavior Driven Development by ExampleBehavior Driven Development by Example
Behavior Driven Development by Example
 
Agile Testing Pasadena JUG Aug2009
Agile Testing Pasadena JUG Aug2009Agile Testing Pasadena JUG Aug2009
Agile Testing Pasadena JUG Aug2009
 
Unit testing with Spock Framework
Unit testing with Spock FrameworkUnit testing with Spock Framework
Unit testing with Spock Framework
 
Building Quality with Foundations of Mud
Building Quality with Foundations of MudBuilding Quality with Foundations of Mud
Building Quality with Foundations of Mud
 
Beginners overview of automated testing with Rspec
Beginners overview of automated testing with RspecBeginners overview of automated testing with Rspec
Beginners overview of automated testing with Rspec
 
Building functional Quality Gates with ReportPortal
Building functional Quality Gates with ReportPortalBuilding functional Quality Gates with ReportPortal
Building functional Quality Gates with ReportPortal
 
Lessons Learned in Software Development: QA Infrastructure – Maintaining Rob...
Lessons Learned in Software Development: QA Infrastructure – Maintaining Rob...Lessons Learned in Software Development: QA Infrastructure – Maintaining Rob...
Lessons Learned in Software Development: QA Infrastructure – Maintaining Rob...
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
 
Getting Started With Testing
Getting Started With TestingGetting Started With Testing
Getting Started With Testing
 
GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...
GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...
GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...
 
Cerberus : Framework for Manual and Automated Testing (Web Application)
Cerberus : Framework for Manual and Automated Testing (Web Application)Cerberus : Framework for Manual and Automated Testing (Web Application)
Cerberus : Framework for Manual and Automated Testing (Web Application)
 
Cerberus_Presentation1
Cerberus_Presentation1Cerberus_Presentation1
Cerberus_Presentation1
 
Lafauci dv club oct 2006
Lafauci dv club oct 2006Lafauci dv club oct 2006
Lafauci dv club oct 2006
 
Writing useful automated tests for the single page applications you build
Writing useful automated tests for the single page applications you buildWriting useful automated tests for the single page applications you build
Writing useful automated tests for the single page applications you build
 
Rethinking Testing
Rethinking TestingRethinking Testing
Rethinking Testing
 
Deliver Faster with BDD/TDD - Designing Automated Tests That Don't Suck
Deliver Faster with BDD/TDD - Designing Automated Tests That Don't SuckDeliver Faster with BDD/TDD - Designing Automated Tests That Don't Suck
Deliver Faster with BDD/TDD - Designing Automated Tests That Don't Suck
 

Más de thehoagie

Converting your JS library to a jQuery plugin
Converting your JS library to a jQuery pluginConverting your JS library to a jQuery plugin
Converting your JS library to a jQuery plugin
thehoagie
 

Más de thehoagie (10)

Pair programming
Pair programmingPair programming
Pair programming
 
Docker presentation
Docker presentationDocker presentation
Docker presentation
 
Database 101
Database 101Database 101
Database 101
 
Hubot
HubotHubot
Hubot
 
Null object pattern
Null object patternNull object pattern
Null object pattern
 
Big tables and you - Keeping DDL operatations fast
Big tables and you - Keeping DDL operatations fastBig tables and you - Keeping DDL operatations fast
Big tables and you - Keeping DDL operatations fast
 
Angular.js - An introduction for the unitiated
Angular.js - An introduction for the unitiatedAngular.js - An introduction for the unitiated
Angular.js - An introduction for the unitiated
 
Regular expression presentation for the HUB
Regular expression presentation for the HUBRegular expression presentation for the HUB
Regular expression presentation for the HUB
 
Converting your JS library to a jQuery plugin
Converting your JS library to a jQuery pluginConverting your JS library to a jQuery plugin
Converting your JS library to a jQuery plugin
 
Active records before_type_cast
Active records before_type_castActive records before_type_cast
Active records before_type_cast
 

Último

Último (20)

"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
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
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

Testing

  • 2. Why Test? To prevent regression Refactoring safety net Posterity of intention Doubles as documentation To expose sub-optimal code design “Proving your work” Fixes are more expensive the later it is detected*
  • 3. Cost of Defects Stage Cost Requirements Time to rewrite requirement Coding Addtl. Hours for engineer QA Addtl. Hours for engineer + PM + QA User Acceptance Testing Addtl. Hours eng + PM + QA + customer Production Addtl. Hours eng + support + PM + customer + QA. Reputational loss. Fixing production data. 10x more expensive if bug found in Production than in Requirements
  • 4. The Delivery Pipeline Dream Branch merged CI runs tests Tests pass Deploys to production JIRA updated “Trust your test suite with your life” In 2012 Github deployed 12,602 times. Busiest day saw 175 deploys.
  • 5. What Makes a Good Test? Testing the interface Good enough coverage, but not burdensome Considers edge cases Clear, concise, comprehensive, correct Verify that you’ve met the stated requirements
  • 6. When Tests Go Bad Brittleness (mocking too much, testing implementation, etc) Unreliable (Full stack tests reliant on timing guesswork) Sluggishness Incomprehensible Size of test suite*
  • 9. What Should I Test? Good rule of thumb: If you are manually setting up data (Rails console, other REPL, etc) and testing a change you are making, this should be your test Same requirements as what the US considers patentable: “clever or non-obvious” Aim for 80% test coverage - Complete coverage is asymptotic Regressions (“Fool me once...”) Code to be refactored
  • 10. Test Types Unit (component) Integration Full stack (e.g. “browser”) Functional tests (e.g. “controller” aka “black box”) Manual Testing (QA) Performance/Stress/Load A/B End to End
  • 11. Unit Testing Demo Lead.mobile - Context, it, Factory pattern, expectation matcher, running tests Lead.determine_business_unit_id - code branches, build vs create, running context Lead.import_addresses_from_identifier_field - decomposing, stubbing
  • 12. Controller / Functional Testing Demo LeadsController.new - before/after hooks, missing records, traits, ivar, type matchers, multiple assertions
  • 13. Full Stack (Browser) Test Demo AuthenticationSpec - feature, Capybara definitions
  • 14. Summary Testing is not an action taken “after the fact” that is meant to check a box Proper testing helps guide code structure The extreme of this is TDD (Test Driven Development) where tests are written (and fail) before the code is written that allows the tests to pass Lower defect count Generally results in smaller, focused methods Being a better tester will make you a better developer

Notas del editor

  1. https://github.com/blog/1241-deploying-at-github
  2. https://www.relishapp.com/rspec/rspec-expectations/v/3-4/docs/built-in-matchers/type-matchers