Delphi Code Coverage
This is a clone of the original repository on http://code.google.com/p/delphi-code-coverage This readme is a transscript of the original project page on Google Code.
This tool was mainly developed by Christer Fahlgreen. He blogged about this tool in 2010.
I fixed some memory leaks and added some extras:
- Support for Environment Variables in Parameters and the List of source paths (see
- the possibility to exclude specific units in the units file (see
-uf) by prepending a "!" before the unit name
- a "Verbose" switch (
-v) for the output
- the tool outputs now (without the verbose switch) just the errors and a summary of the coverage on the console
Delphi Code Coverage is a simple Code Coverage tool for Delphi that creates code coverage reports based on detailed MAP files.
Please also check out this project as it adds a wizard to the Delphi IDE to help create configuration and launch Delphi Code Coverage.
The project you want to run a code coverage report for must have a "debug" configuration that generates a detailed MAP file.
What kind of code coverage does it do
Delphi Code Coverage currently only measures "line coverage", i.e. it will track each line that code was generated for and mark it if it was executed.
Coverage of DLLs and BPLs
For applications who uses Borland Package Libraries (which are essentially DLLs) or external DLLs, DCC will attempt to load a .map file for each DLL and if it exists and units in those libraries are part of the covered units, code coverage will span the DLL/BPL loaded as part of the application. The .map file need to exist in the same directory as the dll that was loaded.
unzip the file and put it for example in your Delphi installations "bin" directory or somewhere where it is in
You may also want to try out the release candidate version for 1.0
All parameters understand also environment variables in batch style (e.g. %WINDIR% etc.)
If a file is used for the source directories (see
-spf) there are also Environment variables allowed.
It is possibile to exclude specific units in the units file (see
-uf) by prepending a "!" before the unit name.
Open a command line prompt in the directory where your compiled application and executable is.
CodeCoverage -m TestApp.map -e TestApp.exe -u TestUnit TestUnit2 -xml -html
HTML output (specify
-html as a parameter)
For each unit there will be a unit.html with a summary of the coverage, followed by the source marked up. Green lines were covered. Red lines were not covered lines. The other lines didn't have code generated for it. There is also a CodeCoverage_summary.html file that summarizes the coverage and has links to the generated unit reports.
XML output (specify
-xml as a parameter)
A summary xml report called CodeCoverage_summary.xml is generated in the output directory that is compatible with the xml output from EMMA.
Emma output (specify
-emma as a parameter)
It is now possible to create EMMA compatible output which allows for using emma to merge multiple code coverage runs as well as using emma for generating reports.
DCC is compatible with Delphi 2010, XE and XE2 (32-bit), Delphi 2006, Delphi 5. If you find that it works for other Delphi versions, please let us know so that we can add to the list.
You can integrate the xml report using the Hudson EMMA plugin. The html report can be integrated using the HTML Publisher plugin.
The 1.0 release was made possible through the generous support of DevFactory.
This project was inspired by great tools in the Java world such as Emma. This project has been lingering in an unfinished form on my harddrive for more than a year. Finally it slipped out.
|The map file used as input|
|The executable to run|
|The directory where the source can be found|
|The directories where the source can be found|
|Use source directories listed in the file pointed to by filename. One directory per line in the file|
|The directory where the output files will be put - note - the directory must exist|
|The units that shall be checked for code coverage|
|Cover units listed in the file pointed to by filename. One unit per line in the file|
|Show verbose output|
|Parse the project file for source dirs|
|Parameters to pass on to the application that shall be checked for code coverage. ^ is an escape character|
|Log events to a text log file. Default file name is: Delphi-Code-Coverage-Debug.log|
|Log events to the Windows API OutputDebugString|
|Include File Extension - This will stop "Common.Encodings" being 'converted' to "Common"|
|Exclude File Extension - This will 'converted' "Common.Encodings.pas" to "Common.Encodings" (and sadly, "Common.Encodings" to "Common"). This is on by default.|
|Generate emma coverage output - Generate emma output as 'coverage.es' in the output directory.|
|Generate separate meta and coverage files when generating emma output - 'coverage.em' and 'coverage.ec' will be generated for meta data and coverage data. NOTE: Needs -emma as well.|
|Generate xml coverage output - Generate xml output as 'CodeCoverage_Summary.xml' in the output directory.|
|Generate html coverage output - Generate html output as 'CodeCoverage_Summary.html' in the output directory.|
|Create a separate namespace (the namespace name will be the name of the module without extension) ONLY for the listed units within the module|
|Create a separate namespace with the given name for the listed dll:s. All modules loaded in those module(s) will be namespaced.|