SlideShare a Scribd company logo
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

More Related Content

PDF
Git Pro Tips
PPTX
Karate for Complex Web-Service API Testing by Peter Thomas
PDF
Karate, the black belt of HTTP API testing?
PDF
Karate - Web-Service API Testing Made Simple
PDF
How to Run a 1,000,000 VU Load Test using Apache JMeter and BlazeMeter
PPT
Find and Fix Performance Bottlenecks with New Relic and BlazeMeter
PDF
Karate - powerful and simple framework for REST API automation testing
PDF
Defensive Apex Programming
Git Pro Tips
Karate for Complex Web-Service API Testing by Peter Thomas
Karate, the black belt of HTTP API testing?
Karate - Web-Service API Testing Made Simple
How to Run a 1,000,000 VU Load Test using Apache JMeter and BlazeMeter
Find and Fix Performance Bottlenecks with New Relic and BlazeMeter
Karate - powerful and simple framework for REST API automation testing
Defensive Apex Programming

What's hot (20)

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

Similar to Testing (20)

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

More from thehoagie (10)

PPTX
Pair programming
PDF
Docker presentation
PDF
Database 101
PPTX
Hubot
PDF
Null object pattern
PDF
Big tables and you - Keeping DDL operatations fast
PDF
Angular.js - An introduction for the unitiated
PDF
Regular expression presentation for the HUB
PDF
Converting your JS library to a jQuery plugin
PDF
Active records before_type_cast
Pair programming
Docker presentation
Database 101
Hubot
Null object pattern
Big tables and you - Keeping DDL operatations fast
Angular.js - An introduction for the unitiated
Regular expression presentation for the HUB
Converting your JS library to a jQuery plugin
Active records before_type_cast

Recently uploaded (20)

PPTX
sap open course for s4hana steps from ECC to s4
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Big Data Technologies - Introduction.pptx
PPTX
Spectroscopy.pptx food analysis technology
PDF
cuic standard and advanced reporting.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Approach and Philosophy of On baking technology
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
sap open course for s4hana steps from ECC to s4
Spectral efficient network and resource selection model in 5G networks
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Per capita expenditure prediction using model stacking based on satellite ima...
Big Data Technologies - Introduction.pptx
Spectroscopy.pptx food analysis technology
cuic standard and advanced reporting.pdf
The AUB Centre for AI in Media Proposal.docx
Building Integrated photovoltaic BIPV_UPV.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Mobile App Security Testing_ A Comprehensive Guide.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
NewMind AI Weekly Chronicles - August'25 Week I
Dropbox Q2 2025 Financial Results & Investor Presentation
Approach and Philosophy of On baking technology
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
MIND Revenue Release Quarter 2 2025 Press Release
Reach Out and Touch Someone: Haptics and Empathic Computing
Profit Center Accounting in SAP S/4HANA, S4F28 Col11

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

Editor's Notes

  • #5: https://github.com/blog/1241-deploying-at-github
  • #13: https://www.relishapp.com/rspec/rspec-expectations/v/3-4/docs/built-in-matchers/type-matchers