Visual Studio code coverage configuration and usage step by step

From QT Wikipedia

Jump to: navigation, search

I will try to explain how to know code coverage in application build with visual studio.

First we will need tweak some Linker options. Add /Profile key.

Contents

Profile settings screen shot

 Add profile keyword to linker
Add profile keyword to linker

After building we need open Visual Studio Command Prompt and go to directory where is located vsintr.exe tool in my case tool was located in following location
c:\Program Files\Microsoft Visual Studio 8\Team Tools\Performance Tools\






Covering application

Coverage command executed
Coverage command executed
Then you have build'ed your application copy executable (<compiled filename>.exe) and

<compiled filename>.pdb to the same directory. It's unnecessary if you will use this command specifying full path to vsintr.exe executable. After this step execute following command: vsinstr.exe -coverage <compiled filename>.exe



Starting coverage logger

Coverage logger stopped
Coverage logger stopped
Then start logger witch logs all actions. Logger is started with this command

vsperfcmd.exe -start:coverage -output:testcoverate.coverage


Starting our executable program

Coverage logger stopped
Coverage logger stopped
At this step you can turn on your previously covered program. I mean program to witch "vsinstr.exe -coverage <compiled filename>.exe" command was executed. After that you should see in same directory file called testcoverate.coverage. After program execution you can stop logger with this command

VSPerfCmd.exe -shutdown


Viewing results

Coverage results
Coverage results
After all this procces you can open generated file <testcoverate.coverage> in visual studio.








Conclusions

So coverage analysis is quiet simple then you now what to do :)


Personal tools
Toolbox