There comes a time in every developer’s life when they realize they need to write better tests.

Whether it’s a console, web, or unit test, they need to write better tests.

If you’re at this point, here are some elements that are important to writing great tests;

  • They should be objective – the result is the result is the result – there is no complex interpretation.
  • They should be measurable – whether they do it or not and how fast or slow do they take.
  • They should NOT require intervention – if someone has to flip 15 switches and jump through 4 hoops to get the desired result, that’s not a test, that’s bad code.
  • They should provide value – if the test fails, it should provide logs so you can diagnose and move forward with.
  • They should cover the scenarios they are built for – if you have multiple interpretations to cover, there is no value in only covering for the first one.
  • They should be current – this is the hardest one, but one of the most important.  Code changes, your tests change with it.

Follow

Want more? Check out my book Code Your Way Up – available as an eBook or Paperback on Amazon (CAN and US).  I’m also the co-host of the Remotely Prepared podcast.

Author

Write A Comment