Testing sad-paths

29
Testing the Sad Paths

Transcript of Testing sad-paths

Page 1: Testing sad-paths

Testing the Sad Paths

Page 2: Testing sad-paths

About Me• 20 years of developing web apps

• Doing TDD/BDD since 2001

• Working with Ruby for the last 8 years

Page 3: Testing sad-paths

Teespring

• ~ 100,000 lines of code in the web app

• ~ 5,000 Requests / 800 pages per minute

• ~ 7 million shirts sold in 2014

• Real people making real money

Page 4: Testing sad-paths

Teespring• We try to TDD as much as possible

• We do serious code review

• We use a CI Server to test pull requests

• We also do manual QA before deploying

• (And, one other thing - we’re hiring!)

Page 5: Testing sad-paths

Some Tools We Use• Ruby/Rails/(and JS) Stack

• Rspec

• Capybara

• Webmock/VCR

• SimpleCov

Page 6: Testing sad-paths

What Do We Test?

Page 7: Testing sad-paths
Page 8: Testing sad-paths

The Sad Path

Page 9: Testing sad-paths

The Sad Path

• Happy paths are usually tested and built first

• Sad paths can be overlooked

• Many users will find the sad path

Page 10: Testing sad-paths
Page 11: Testing sad-paths

Your QA teamThey often deal with the sad paths while manual testing

Page 12: Testing sad-paths

Error Handling

• Defensive Coding

• Handling expected problems

• Logging/Tracking error information

• “Exceptional Ruby” covers this topic really well

Page 13: Testing sad-paths

Failure Modes

Page 14: Testing sad-paths

Three Types of Failure

• User does something wrong

• System does something wrong

• Transient - overloaded, slow, unavailable, etc.

Page 15: Testing sad-paths

Testing for User Errors

Page 16: Testing sad-paths
Page 17: Testing sad-paths
Page 18: Testing sad-paths

Things to Consider• What constitutes valid vs. invalid input?

• Where can invalid input possibly enter the system?

• How do you deal with invalid input in other parts if the system?

Page 19: Testing sad-paths

Logic Errors

Page 20: Testing sad-paths
Page 21: Testing sad-paths
Page 22: Testing sad-paths
Page 23: Testing sad-paths

Things to Consider• Almost any part of your system can fail.

• Handling vs. preventing failure

• Nil is a tenacious enemy

• How will you recover from errors?

Page 24: Testing sad-paths

Transient Errors

Page 25: Testing sad-paths
Page 26: Testing sad-paths
Page 27: Testing sad-paths

Things to Consider• Is it even worth retrying?

• Retrying forever is probably a bad thing.

• How do you communicate to users to come back later?

• How do you isolate the failure to a small area?

Page 28: Testing sad-paths

Questions?

Page 29: Testing sad-paths

Links• http://rspec.info/

• https://cukes.info/

• https://github.com/jnicklas/capybara

• https://github.com/bblimke/webmock

• https://github.com/vcr/vcr

• https://github.com/colszowka/simplecov

• http://exceptionalruby.com/