Sunday, August 30, 2015

Code Coverage with Visual Studio Performance Tools


Steps for recording code coverage without relying on Unit Test Cases for a Web Application 

This shows how to record coverage for WCF services hosted over IIS, this method of recording code coverage has no reliance on UTC(s). 
  1. Instrument all application DLL(s) in all the applications (Web & App Server both, depending on the requirement).
    1. Open Visual Studio Native Command Prompt X64 in administrative mode 
    2. Go to the bin directory of the application 
    3. Run following command for each application DLL that you want to record(It will instrument the DLL with symbols) VSINSTR /COVERAGE <DLL Name>
    4. Above command will generate an instrumented DLL(s), original ones would be renamed as <filename>.dll.orig
  2. Stop IIS IISRESET -STOP
  3. Start the performance recorder daemon 
    1. Open Visual Studio Native Command Prompt X64 in administrative mode and run (either 1st option or 2nd option)
      1. START VSPERFMON /COVERAGE /OUTPUT:<FileName>.coverage /CROSSSESSION /USER:Everyone
      2. VSPERFCMD /START:COVERAGE /OUTPUT:<FILENAME>.coverage /CROSSSESSION /USER:Everyone  
    2. Above command should spawn a new command window and you will see a running process there. (if 1st option is chosen; 2nd option will spawn the daemon in background) 
  4. Start the IIS IISRESET -START
  5. Let the application run and tested by the testers (functional/system test cases), if you are recording the coverage with VSPERFMON then you should see W3WP.exe listed on the newly spawned command window. 
  6. Once the functional and regression testing is done, stop the IIS using following command  IISRESET -STOP
  7. Stop the daemon VSPERFCMD /SHUTDOWN 
  8. Open the coverage file by double clicking on a machine that has Visual Studio
  X64:: is just a prompt set by using prompt command to avoid showing long command paths
>PROMPT X64::









No comments:

Post a Comment