Running tests


To run the tests, simply run the project as normal.

If you are on a Mac, you may need to first switch to the Run and Debug view: Run and Debug view

And then select Run Tests (Mac): Run and Debug (Mac) option)

If you want, you can use breakpoints to observe code in the debugger as tests are running.

You should see something like this in the Terminal: Unit test output

From that, I can see that 6 different assertions (CHECK or REQUIRE) were run as part of 2 different TEST_CASES. I failed one of the assertions which means I failed the one test it was a part of.

I can see that the test I failed was "distance" which is on line 52 of the tester file. I can see that the assertion I failed was CHECK( distance(x2, y2, x1, y1) == Approx(8.0) ); which is on line 64. Below that is shown what values were used as part of that test. CHECK( 5.0 == Approx(8.0) ) tells me that my call to distance(x2, y2, x1, y1) must have produced the value 5.0 and that is what was compared to 8.0.

To track down errors, you can print debug information - it will appear by the error messages in the output.

If your program crashes while running, you likely won't see any test output. In that case, try running in the debugger to find where it is crashing.