Udostępnij za pośrednictwem


Collecting code coverage data as part of automated test.

We were recently working on a case, which was related to collecting code coverage information for a web application, as part of automated testing. We found a specific requirement to collect code coverage data during the course of this, and thought of sharing it here.

Setup

· We have a web application for which a coded UI test has been recorded.

· We are collecting code coverage information for the web application dll as part of the coded UI test execution.

· Test execution is automated using MTM and we have a lab with one web server where the tests are running. (Test agent running interactively)

· Test agent is configured to run interactively in order to run coded UI test, from MTM during environment setup (as shown below)

srraj

Results

 

We were unable to collect code coverage data with the above configuration, and was getting a warning message as below, in the test results:

Warning Diagnostics and data collection for IIS is configured for IntelliTrace. Administrative privileges are required for IIS collection. Use the Team Test Agent Configuration tool to configure your agent as a user that has administrative privileges or turn off IIS data collection in the Test Settings dialog. Code Coverage <MachineName.domain.com>

Changes made to collect the coverage data

Later we found that to collect code coverage data, there is a specific requirement to configure the test agent manually by logging in to the test agent machine itself, with administrative privileges. This is the reason why we initially got the warning message, when test agent was automatically configured from MTM.

This is mentioned in the below MSDN article as well:
https://msdn.microsoft.com/library/hh698492(v=vs.110).aspx

Configure Test Agent
Remote collection of ASP.NET Client Proxy for IntelliTrace and Test Impact, IntelliTrace and Test Impact requires manual configuration of elevated permissions. If code coverage is enabled with any of these collectors, log on to the Test Agent machine, open the Test Agent Configuration Tool and configure the Test Agent service to run with Administrator credentials.

If Code Coverage is not enabled with above collectors, this step is not necessary.

Once the agent was configured by logging in to the test agent machine directly, we were able to get the code coverage results successfully.

Hope this information helps!

Content created by – Sreeraj Rajendran
Content reviewed by – Romit Gulati