Loading
Current section: Test Structure 6 exercises
Problem

Isolating Tests with Test Blocks

Transcript

00:00 It looks like a bug has found its way into our code. How do I know this? Well, by running the test, of course. Once I do, I can see that there's an error indicating a failed assertion. But if you take a look at the exact place this error is thrown, it points at the line 28, which is this throw statement, and not the individual expects that would indicate the problematic code.

00:19 You can, of course, dive through the stack trace and eventually find it out, but you would be spending time debugging tests instead of solving the issue. More to that, since both of our expect calls happen in the same scope, if one of them throws an error, the other will not even be called because the process will exit. And having the full picture, the high-level overview

00:37 of all test cases and their results is absolutely essential because they help you solve bugs. So in this exercise, your task would be to introduce a test function and wrap existing tests in it to provide isolation and also report individual test runs separately, whether the test passes or fails. And once you do, try to see if you can spot the problematic test