Testing Toolbox
I want to...
...give you a better set of testing tools
...help you test your apps more effectively
...give you something you can use tomorrow
Why do we test?
We don't want to be this guy...
Pros
Feel safe deploying
Maintainability
Better designs
Cons
Bad tests == harder maintenance
Takes time
Thus, perception of low ROI
But what is high-ROI?
High-Level,
High-ROI Testing
gem 'tarantula' # 'tarantula-rails3'
"Fuzzy spider" your site
Crawl links, fuzz test forms
Find 404s, 500s, etc
Teach it to log in
Set it and forget it (until you introduce a bug)
gem 'jasmine'
"rspec for JS" (unit testing lib)
jasmine-jstd-adapter (jsTestDriver)
Auto-run your specs on IE 6+, iPhone, Firefox, etc
Even with 1 spec, you'll find weird IE problems quicker (e.g., syntax)
Browser Simulators
Hook 'em up to JSTD, they become Jasmine spec runners!
IETester (IE5.5+ in a single Windows app)
Apple's iOS Simulator (iPhone + iPad, in iOS SDK)
Android Emulator (Android SDK)
BlackBerry simulator (painful)
Screen Reader Simulators
Another type of browser
On a Mac? You have one built into Safari
Try out your site and see what the blind get
Details:
456 Berea Street article
Email Simulators
Email on Acid (emailonacid.com)
Paid, but worth it if you send a lot of email
Tests Gmail, Yahoo Mail, Thunderbird, Lotus Notes, etc
See all those Outlook bugs in one place
Selenium IDE
Testing a GUI? Or no tests? Put a Selenium script behind it
Record your actions in a browser, make assertions
Use JavaScript when you need more logic
Low-Level Testing, Accelerated
Pick one: "rspec" or "test/unit"
Using test/unit?
gem 'shoulda'
gem 'mocha'
gem 'autotest' # 'ZenTest'
Runs your tests as soon as you change then
Leave it up on a separate monitor
gem 'guard'
An alternative
Does more than tests
gem 'timecop'
Make time-based tests a breeze
Timecop.travel
and
Timecop.freeze
gem 'fakeweb'
gem 'webmock'
Easily stub HTTP interactions
Great for testing integration with web services
Sucks because you have to copypasta the XML, JSON, etc
So, best used in combination with...
gem 'vcr'
Record HTTP interactions to cassettes (
.yml
files)
Replay them during future test runs
Fast, deterministic, accurate tests
Saves tons of time
gem 'factory_girl_rails'
Better than fixtures
Build objects for testing
Powerful definitions
gem 'fabrication'
factory_girl
has a Rails bias
fabrication
is up and coming
I haven't used it much but it looks awesome
This is what's in my toolbox
I hope I've given you something you can use tomorrow
Thanks!