Pre-requisite
- Build having dll’s/exe along with their corresponding pdb’s
- VS 2008
Limitations:
- Code coverage of VSTS is limited to 32 bit.
- 64 bit dll, during instrumentation will throw error. This implies that instrumentation is successful but the 64 bit dll are forcibly converted to 32 bit. We can only proceed only if its compatible on both 32 & 64 bits
- The tool must be installed on c:\programfiles and not on c:\programfiles<x86>.
Steps to perform code coverage
Locating Application Binaries
- Open Bin folder( should have dll’s & corresponding pdb’s)
- Make sure that Bin folder is not read only
- Ensure to backup dll’s in case of roll back
Instrumentation of Binaries
- Run cmd window using administrator account
- Change to directory
- (For 32 bit)
C:\Program Files\Microsoft Visual Studio 9.0\Team Tools\Performance Tools>
- (For 64 bit- Ensure to install vanguard tool)
C:\Program Files\VSCC 10.0>
- Run cmd window using administrator account
- Change to directory
- Execute “vsinstr /coverage <assemblyname>” for all your binaries
If your binary name is ‘test.dll’, then type
vsinstr /coverage D:\Test\TestDLLApp\TestDLLApp\bin\Debug\test.dll
- After instrumentation we will get 2 additional files. The original Test.dll will be replaced with test.dll.orig and a new Test.dll & Test.instr files will be created
- Repeat the same for other dll’s
- Alternatively we can also use the following command: (ensure that we have vsinstr and vsperfcmd utilities in the working folder).
for %i in (*.dll) do vsinstr /coverage %i
Start Code coverage monitoring process
- In command prompt type “vsperfcmd /start:coverage /output:yourfilename.coverage
E.g. If want to save coverage file in particular folder then give the path of that folder.
vsperfcmd /start:coverage /output:c:\test\sample.coverage
- Verify if the coverage file is successfully created
Execute Tests
- Execute the tests (Manual + Automation)
End the code coverage monitoring process
- In the command prompt, type vsperfcmd /shutdown
- This shuts down the coverage monitor and saves the coverage data in the coverage file.(w.r.t to above example in c:\test\sample.coverage)
Generate Code coverage report
Now click on import button and select the path of .coverage file
Note: In order to retain the results it’s necessary to have the .coverage file along with the instrumented binaries