Skip to content

Instantly share code, notes, and snippets.

@kjhf
Created December 30, 2020 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kjhf/20031165277fdc9c01803b3b2532f778 to your computer and use it in GitHub Desktop.
Save kjhf/20031165277fdc9c01803b3b2532f778 to your computer and use it in GitHub Desktop.
Unit tests edge cases philosophy

On ordering a beer...

Positive tests:

  • Order a beer.
  • Order two beers.
  • Order a beer then another beer.
  • Order a round. Make sure all friends receive their beers (and the correct one)
  • Have several friends order beers at the same time.
  • Order a beer for later.
  • Order the menu.
  • Jump behind the bar, reorder the beers. Jump back, order a beer.

Negative tests:

  • Order 0 beers.
  • Order -1 beers.
  • Order 3.14 beers.
  • Order null beers.
  • Order uint.max beers.
  • Order a beer but the bar has run out of stock.
  • Order the bartender.
  • Order a sfdeljknesv.
  • Order beers in a different language/protocol
  • Order a b̶̛̳̫̭͈̝̗̤̲̺̜͍̹̻͇͖̼͈̙̜͆̾̔̑̊̌̿ͫ̒̀̒̄ͤͫͩͨ̏͘̕͞ě̴̸̟͖͕͇͊ͪ͒͜ē̸̌̆ͯ̏͛͌̚͞҉҉̝̤͓̥̱͔̱̩̹̮̲͚̙̫͚͕̭ͅr̷̢͖̺͉̺͚̱̲̯͙̲̱̹̩̼̥̊̂ͩ̐ͮ̏ͫ̐́
  • Order a 🍺
  • Sell a beer
  • Return the ordered beers
  • Order a beer in IE5.

Failure tests:

  • Order a be^C
  • Order a beer. The bartender goes to the bathroom and doesn't return.
  • Unhook the tap and order a beer.
  • Break all the glassware and order a beer.
  • Set the bar on fire and orders a beer.
  • Kill the bartender and order a beer.

Security tests:

  • Order <script>alert('beer')</script>. Orders '); drop table orders; --Order AAAAAAAAAAAAAAAAAAAAAAAAA
  • Order a DROP TABLE; --
  • Bypass the bartender and pours <img src=x onerror=alert('xss') /> beers for someone else.
  • Order 1 ; select * from liquors; -- beers.
  • Wait for someone else to order, take the drink.

Many of these from: https://www.sempf.net/post/On-Testing1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment