Generating an HTML report using coverage

Using the coverage tool, generate an HTML visual coverage report. This is useful because we can drill into the source code and see what lines were not exercised in the test procedures.

Reading a coverage report without reading the source code is not very useful. It may be tempting to compare two different projects based on the coverage percentages. But unless the actual code is analyzed, this type of comparison can lead to faulty conclusions about the quality of software.

How to do it…

With these steps, we will explore creating a nicely viewable HTML coverage report.

  1. Generate coverage metrics by following the steps in Installing and running coverage on your test suite recipe and only running the first test suite (which has resulted in less than 100 percent coverage).
  2. Generate an HTML report by typing: coverage.html.
  3. Open htmlcov/index.html using your favorite browser and inspect the overall report.
    How to do it…
  4. Click on network, and scroll down to see where the event clearing logic wasn't exercised due to no clearing events being processed.
    How to do it…

How it works...

The coverage tool has a built-in feature to generate an HTML report. This provides a powerful way to visually inspect the source code and see what lines were not executed.

By looking at this report, we can clearly see that the lines not executed involve the lack of clearing network events that are being processed. This can tip us off about another test case which involves clearing events that need to be drafted.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.35.185