Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The art of writing mature tests

The art of writing mature tests

We all know how important testing is in SDLC but the last thing you want to do when you're building the next big thing is to struggle with tests. After writing and rewriting hundreds of tests, this is an attempt to save you from hours of frustration by sharing my learnings on how to write tests which don’t hold you back in innovating faster.

Deepak Pathania

March 30, 2018
Tweet

More Decks by Deepak Pathania

Other Decks in Programming

Transcript

  1. Motivation
 Frustration. - Writing a lot of tests and then

    modifying them all because of a slight change in the code base. - Spending more time fixing tests than writing code. - Going through tons of fixtures to debug failing tests.
  2. Motivation
 Frustration. - Mocking and stubbing and faking and spying

    and crying. - Hoping Praying flaky tests don’t show up again in pipelines. - Staring at assertion failures and stack traces aimlessly.
  3. 0. The test monolith ☠ - Neither unit nor integration.

    - High Coupling. No isolation. - Worst of both worlds.
  4. 5. Following poor spec 
 naming conventions. - Using the

    name of the function we are testing as the describe block text.
 - As a thumb rule for writing better descriptions, the describe-it block text should make a proper sentence.
 - A single test description should include the unit of work, the scenario and 
 the expected outcome.
  5. Test Design - Lay down constraints to define boundary. -

    Identify actors, scenarios and permutations. - Think first, test later.