© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2023
D. IrvineBuild Your Own Test Frameworkhttps://doi.org/10.1007/978-1-4842-9247-1_6

6. Formatting Expectation Errors

Daniel Irvine1  
(1)
London, UK
 

One of the signs of a “good” test is that when it fails, it very quickly pinpoints to you why it failed so that you can get to fixing the problem quickly.

To that end, our current expectation errors are not as helpful as they could be. In Chapter 5, you saw how matchers are used to output “pretty” expectation failure messages. However, when a failure occurs, we’ll also get an exception stack trace printout, and it’s this that we can improve on.

In this chapter, we’ll take the stack trace and rework it into something ...

Get Build Your Own Test Framework: A Practical Guide to Writing Better Automated Tests now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.