Noah Sussman
NYC Testers Meetup at Viacom, November 2014
Dopplegangers!
A discussion about
Collaborators,
Fakes,
and
Mocks
✤ jq: JSON query language
✤ Python SimpleHTTPServer
✤ JSON API spoofing
✤ Chrome Inspector
✤ The BASE tag — forgotten relic of ancient power!
SimpleTools For ComplicatedTasks
✤ Debugging is much
harder than writing
code in the first place.
✤ Automated tests that
you cannot debug are
worse than useless: such
tests provide a FALSE
sense of confidence.
Why not build a framework?
Ironies of automation
✤ Testing is harder than writing the code under test
✤ Testing is yet another layer(s) of complexity
✤ Tests that are opaque dramatically increase cost while
adding zero value
✤ There is NO value in flaky, hard-to-debug tests
✤ rm -rf * SERIOUSLY
jq the JSON parser
✤ transform any data source into JSON
✤ transform JSON into executable code
✤ create ETL pipelines
✤ unlimited POWER
jq: SQL queries for JSON
✤ Compiled C binary, just like find, grep and awk
✤ Does one thing and does it well
✤ Can transform any text input into valid JSON
✤ Only emits valid JSON. Anything else is a fatal error.
✤ Extremely fast, if you’re into that ;-)
Convert plain text logs to JSON.
Convert plain text logs to JSON.
Validate data integrity.
JSON SchemaValidation
Chrome Inspector NetworkTab
✤ View all the assets that were loaded by the browser
✤ Watch XHR requests happen in real time
✤ Download cached copies of JSON API responses!
Visual Inspection
✤ Examine HTTP conversations in the Net tab
✤ Locate JSON feeds
✤ Download JSON documents
✤ “Replay” documents in test using SimpleHTTPServer
Sufficiently advanced fakes…
✤ …are indistinguishable from production services
A Fake Chat Bot
✤ 61 lines of HIGHLY LEGIBLE bash and jq
✤ Does one thing and does it well
✤ Does NOT provide most chatbot features
✤ Indistinguishable from a chatbot in practice
✤ Jenkins plugins are integral.
Break HipChat you might break
Jenkins!
✤ No matter how hard the bot
goes down, you only ever have
to debug 61 lines to restore your
mission-critical Jenkins status
announcements!
Why not use a framework?
A chat bot is a stack
Jenkins JSON API
That’s it! It acts like a bot (sort of).
A New Jersey solution in the wild!
✤ Simplicity and design are equally important
until you have to pick one; then pick simplicity.
✤ Modern business practices assume that there is
no functional upper limit on system complexity.
MIT vs. New Jersey!
a.k.a “worse is better”
The BASE tag
✤ Overrides the root URL of an HTML page.
✤ Saturate local HTML pages with production assets!
Handling plutonium: get ready for it
✤ Eventually your automation will detect a widespread
antipattern.
✤ Since your automation made the discovery, you will by
definition know the nature of the bug(s) better than
anyone else.
✤ It’s SUPER scary to factor out a widespread pattern.
✤ tl;dr: you’ll want to fix it, though it’ll be hard.
Thanks!
✤ I’ll take a few questions now…
✤ Follow me on twitter: @noahsussman

Dopplegangers in the web sphere: Decoupling Web Service Components In Test

  • 1.
    Noah Sussman NYC TestersMeetup at Viacom, November 2014 Dopplegangers! A discussion about Collaborators, Fakes, and Mocks
  • 4.
    ✤ jq: JSONquery language ✤ Python SimpleHTTPServer ✤ JSON API spoofing ✤ Chrome Inspector ✤ The BASE tag — forgotten relic of ancient power! SimpleTools For ComplicatedTasks
  • 5.
    ✤ Debugging ismuch harder than writing code in the first place. ✤ Automated tests that you cannot debug are worse than useless: such tests provide a FALSE sense of confidence. Why not build a framework?
  • 6.
    Ironies of automation ✤Testing is harder than writing the code under test ✤ Testing is yet another layer(s) of complexity ✤ Tests that are opaque dramatically increase cost while adding zero value ✤ There is NO value in flaky, hard-to-debug tests ✤ rm -rf * SERIOUSLY
  • 7.
    jq the JSONparser ✤ transform any data source into JSON ✤ transform JSON into executable code ✤ create ETL pipelines ✤ unlimited POWER
  • 8.
    jq: SQL queriesfor JSON ✤ Compiled C binary, just like find, grep and awk ✤ Does one thing and does it well ✤ Can transform any text input into valid JSON ✤ Only emits valid JSON. Anything else is a fatal error. ✤ Extremely fast, if you’re into that ;-)
  • 9.
    Convert plain textlogs to JSON.
  • 10.
    Convert plain textlogs to JSON.
  • 11.
  • 13.
  • 22.
    Chrome Inspector NetworkTab ✤View all the assets that were loaded by the browser ✤ Watch XHR requests happen in real time ✤ Download cached copies of JSON API responses!
  • 25.
    Visual Inspection ✤ ExamineHTTP conversations in the Net tab ✤ Locate JSON feeds ✤ Download JSON documents ✤ “Replay” documents in test using SimpleHTTPServer
  • 30.
    Sufficiently advanced fakes… ✤…are indistinguishable from production services
  • 31.
    A Fake ChatBot ✤ 61 lines of HIGHLY LEGIBLE bash and jq ✤ Does one thing and does it well ✤ Does NOT provide most chatbot features ✤ Indistinguishable from a chatbot in practice
  • 32.
    ✤ Jenkins pluginsare integral. Break HipChat you might break Jenkins! ✤ No matter how hard the bot goes down, you only ever have to debug 61 lines to restore your mission-critical Jenkins status announcements! Why not use a framework?
  • 33.
    A chat botis a stack
  • 35.
  • 37.
    That’s it! Itacts like a bot (sort of).
  • 38.
    A New Jerseysolution in the wild!
  • 40.
    ✤ Simplicity anddesign are equally important until you have to pick one; then pick simplicity. ✤ Modern business practices assume that there is no functional upper limit on system complexity. MIT vs. New Jersey! a.k.a “worse is better”
  • 41.
    The BASE tag ✤Overrides the root URL of an HTML page. ✤ Saturate local HTML pages with production assets!
  • 43.
    Handling plutonium: getready for it ✤ Eventually your automation will detect a widespread antipattern. ✤ Since your automation made the discovery, you will by definition know the nature of the bug(s) better than anyone else. ✤ It’s SUPER scary to factor out a widespread pattern. ✤ tl;dr: you’ll want to fix it, though it’ll be hard.
  • 44.
    Thanks! ✤ I’ll takea few questions now… ✤ Follow me on twitter: @noahsussman