다음을 통해 공유


Code Coverage for Azure Services

Overview:

This document describes how to perform code coverage of Azure services by running them on dev fabric. It first describes the issues faced and then the methodology using which code coverage was obtained for Azure services.

Issues faced:

Code coverage for Azure services could not be done within Visual Studio.

Un-Instrumented DLLs

·         Deployed the Azure service on dev fabric

·         Copied the symbol files in the same folder where the DLL exists at \Users\..\AppData\Local\dftmp\s0\deployment(N)\res\..\AspNetTemp\aspNetTemp\..

·         Opened the coverage tab in testrunconfig and added the DLL from \Users\..\AppData\Local\dftmp\s0\deployment(N)\res\..\AspNetTemp\aspNetTemp\..

·         Got an error, Error VSP1024: Unable to open file \Users\..\AppData\Local\dftmp\s0\deployment(N)\res\..\AspNetTemp\aspNetTemp\..' for writing

Reason: This is because VS is trying to instrument a DLL which is already in use.

Instrumented DLLs

·         Instrumented the DLLs

·         Deployed the Azure service on dev fabric

·         Opened the coverage tab in testrunconfig and added the DLL from \Users\..\AppData\Local\dftmp\s0\deployment(N)\res\..\AspNetTemp\aspNetTemp\..

·         Got an error, Error VSP1018: VSInstr does not support processing binaries that are already instrumented

Reason: This is because VS is trying to instrument an already instrumented DLL.

Code Coverage Methodology

Since the Azure services for which we want to obtain the coverage are running on dev fabric which is a 64-bit process, we should use Visual Studio 64-bit tools. So either launch VS 64-bit command prompt or open command prompt and change directory to \Program Files\Microsoft Visual Studio 10.0\Team Tools\Performance Tools\x64

Steps:

·         Open command prompt in privileged mode.

·         Change directory to \Program Files\Microsoft Visual Studio 10.0\Team Tools\Performance Tools\x64

·         Instrument your DLLs for the Azure service by running the command vsinstr /coverage “…\abc.dll”

·         Start coverage monitor by running the command vsperfcmd /start:coverage /output:”Test.coverage”

·         Deploy the instrumented Azure service on dev fabric.

o   Go to Programs->Windows Azure SDK v1.2->Windows Azure SDK Command Prompt 
o   Type csrun /devfabric:start
o   Type csrun /devstore:start
o   Type csrun /run:"...\abc.csx";"...\ServiceConfiguration.cscfg" 

·         Run your tests pointing the instrumented Azure service deployed on dev fabric.

·         Stop the coverage monitor by running the command vsperfcmd /shutdown

o   If you see the error Waiting for the process …\WaWebHost.exe to shutdown, shut down the dev fabric by using the command /devfabric:shutdown

·         Open the file Test.coverage to find your code coverage results.

Note: The important step here is to start the coverage monitor before deploying the Azure service on dev fabric.