Skip to content

Instantly share code, notes, and snippets.

@instabledesign
Last active October 12, 2018 09:15
Show Gist options
  • Save instabledesign/9a2894ab1855387438bc0fa7a186ed9c to your computer and use it in GitHub Desktop.
Save instabledesign/9a2894ab1855387438bc0fa7a186ed9c to your computer and use it in GitHub Desktop.
Testing guidelines

Testing guidelines

  • use mock, spy and stub on your dependancies
  • count call expectation (and when it should not be called)
  • (try) dont mock what you don't own
  • use dataprovider
  • test edge case (when function need integer test it with negative / positive / 0 and Infinity)
  • test all exit cases (return, exception)
  • you can use dummy object to test abstract code
  • caution with date, filesystem, external ressources
  • you can create base testing class that provide your own mock, assertion, data provider
  • try to avoid algorithm logic in your test code (if/foreach) (except for data provider)
  • dont test native code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment