Cultivate Explicit Diagnostic Tools to Debug Test Failures
Explore how to build explicit diagnostic tools like the with_clues method to debug test failures in Rails system tests. Understand how to capture useful information during exceptions and improve your testing process for long-term maintainability.
We'll cover the following...
A big part of the carrying cost of system tests is the time it takes to diagnose why they are failing when we don’t believe the feature being tested is actually broken. The assertions available to Rails provide only rudimentary assistance. The team will eventually learn to use puts page.html as a diagnostic tool, but let’s take time now to make one that works a bit better.
Let’s wrap puts page.html in a method called with_clues. The with_clues method will take a block of code and, if there is any exception, produce some diagnostic information (currently the page’s ...