O'Reilly logo

RSpec Essentials by Mani Tadayon

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Detecting false negatives and false positives

Tests can fool us with failures when the code actually works fine (false negatives) and successes when the code is broken (false positives). There is no way to completely eliminate false results, but we can reduce their likelihood by keeping tests simple and doing sanity checks. Sometimes our tests might seem like they are not doing enough, or we may seem to be checking for redundant things that we expect never to break. That is simply the price we have to pay to minimize the chance that our tests are fooling us.

Let's cover three useful tactics to reduce false results:

  • Sanity checks
  • Tests for the opposite case
  • Increased specificity of assertions

Detecting false results is a fundamental concern of testing, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required