Skip to content

DTest and CodeCoverage

Michael Baas edited this page Jun 7, 2024 · 1 revision

Why

DTest has an option to analyze CodeCoverage while running tests. The subject of the Coverage analysis could be the source code that was tested as well as the tests themselves. Coverage itself does not say anything about correctness of code or tests, but it could be a useful metric and is definitely useful to ensure that tests really challenge all parts of the code they are testing.

How

Kai Jäger has written an excellent tool for this purpose: CodeCoverage. It is used internally by DTest. (details in next section)

ad-hoc

The easiest way to perform a coverage analysis is by simply using the switch -coverage when launching DTest.

hard-code it!

However, if you want to run a number of tests repeatedly, it is recommended to do this by setting up a .dyalogtest file which provides additional settings for coverage analysis.

Obtaining the required class

If DTest is able to get it using Tatin, it will dynamically be brought in. Otherwise, you'll need to provide a local copy yourself:

  • download the required version (see initial code in DyalogBuild.dyalog that assigns variable "CodeCoverage" with that version) from Kai's repository.
  • copy the CodeCoverage folder into MyUCMDs
  • or place it elsewhere and set up a config variable "CODECOVERAGE_PATH" that points to the path