Execution Reports for Unit Test
CoverageBrowser imports execution results for all object files that are part of an application. This means that if a unit test uses the same object files as the application, CoverageBrowser can import the execution results of the unit tests and merge them into the code coverage of the compiled application.
For example, the following application consists of three files:
app.cpp
: This file contains themain()
function of the application.library.cpp
: This file contains functions that are called byapp.cpp
.testlibrary.cpp
: This file contains the test code for the functions inlibrary.cpp
. It has its ownmain()
function.
In Microsoft® Windows, the application is compiled with the following commands:
cscl app.cpp /Foapp.obj cscl library.cpp /Folibrary.obj cscl library.obj app.obj /Feapp.exe
The following commands compile the unit test program:
cscl testlibrary.cpp /Fotestlibrary.obj cscl library.obj testlibrary.obj /Fetestlibrary.exe
To import the execution report of the unit tests into the instrumentation database of the main application, two methods can be used:
- The execution of
testlibrary.exe
generates the execution reporttestlibrary.exe.csexe
. This report is then loaded into the measurement databaseapp.exe.csmes
. - The execution of
testlibrary.exe
generates the execution reporttestlibrary.exe.csexe
. This report is then loaded into the measurement database of the test code,testlibrary.exe.csmes
by selecting File > Import Unit Tests in CoverageBrowser (see Importing unit tests).
In both cases, only the code coverage analysis of the file library.cpp
is loaded and the execution report of the test code is ignored.
Coco v7.2.0 ©2024 The Qt Company Ltd.
Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners.