Post on 16-Jul-2015
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!
Simple Tools For Complicated Tasks
✤ 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 ;-)
Chrome Inspector Network Tab
✤ 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
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?
✤ 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.