Delphi – Measuring code coverage in Delphi

code-coveragedelphidunitunit testing

Is there any way to measure code coverage with DUnit? Or are there any free tools accomplishing that? What do you use for that? What code coverage do you usually go for?

Jim McKeeth: Thanks for the detailed answer. I am talking about unit testing in the sense of a TDD approach, not only about unit tests after a failure occured. I'm interested in the code coverage I can achieve with some basic prewritten unit tests.

Best Answer

I have just created a new open source project on Google Code with a basic code coverage tool for Delphi 2010. https://sourceforge.net/projects/delphicodecoverage/

Right now it can measure line coverage but I'm planning to add class and method coverage too.

It generates html reports with a summary as well as marked up source showing you what lines are covered (green), which were not (red) and the rest of the lines that didn't have any code generated for them.

Update: As of version 0.3 of Delphi Code Coverage you can generate XML reports compatible with the Hudson EMMA plugin to display code coverage trends within Hudson.

Update: Version 0.5 brings bug fixes, increased configurability and cleaned up reports

Update: Version 1.0 brings support for emma output, coverage of classes and methods and coverage of DLLs and BPLs

Related Topic