Skip to content

Coverage reports

A coverage report lists each line of your code and how many times the tests ran it. A line with the count 0 is a line that no test reached.

--coverage-lcov writes the report in the lcov format. --coverage-clover writes it as Clover XML. --coverage-cobertura writes it as Cobertura XML. Most build servers and editors read one of them. You can write all of them in one run. This run uses the program from Running tests:

Terminal: coverage
nvs test prices.nvs --coverage-lcov coverage.lcov --coverage-clover coverage.xml  PriceTest    ✓ addsTwentyPercent                0.3 ms    ✓ zeroStaysZero                    0.3 ms    - roundsHalfCents                  0.0 ms      skipped: rounding is not decided yet  0 failed, 2 passed, 1 skipped, 0 flaky in 1 ms  3 of 5 lines run (60.0%)

The output has one more line at the end. It counts the lines that the tests ran.

These are lines from the lcov file. The SF line names the file. Each DA line is a line number and how many times it ran:

SF:prices.nvs
DA:10,2
DA:19,1
DA:25,1
DA:32,0
DA:37,0

Line 10 is in withTax, and the two tests that ran both call it. Line 32 is in the skipped test, so its count is 0. Line 37 is outside every class. nvs test does not run the lines outside a class, so they always have the count 0.

A file in the report is named relative to the folder you run nvs test in. Run it from the root of your repository, so your build server finds the files.

Read more in Reference: nvs test.