简体   繁体   中英

How do I get code coverage colour-coding in Visual Studio based on real production use?

I'm looking at a body of C# code, currently compiled and deployed to an Azure App Service, and used daily in production by hundreds of users. The problem is, I'm not sure which lines of code are actually run in production. There are many if/else blocks that may never be entered, or perhaps only very rarely.

I could start by adding tracing statements throughout the code to gather usage data, but it would take too much time, and I would prefer to use existing tools.

Ideally I would like to flick a switch to start gathering data, and be able to see the results inside Visual Studio. It would be great to be able to see each line of code highlighted to indicate that it has indeed been run over the time period. It would be even better to see how many times each line of code was run.

Visual Studio CodeLens coupled with Application Insights provides the possiblity to see the number of HTTP requests that been serviced by a method in the past 24 hours, which is certainly better than nothing, but doesn't give me the line-by-line detail that I am looking for. https://docs.microsoft.com/en-us/azure/azure-monitor/app/visual-studio-codelens#requests-in-codelens

Visual Studio (Enterprise edition) does provide some code coverage colouring, but only in the context of the execution of unit tests. I'd like to analyze the data based on real production use. https://docs.microsoft.com/en-us/visualstudio/test/using-code-coverage-to-determine-how-much-code-is-being-tested

Is there any tool that provides what I am looking for?

You can use Live Metric Stream in Application insights to know your application code line by line details.

Using Live Metric Stream , we can monitor our live web application in production.

In Live Metric stream we can do the following diagnosis.

  • Get telemetry information in a live when they actually happen.
  • Filter the specific metrics which you want to check.
  • Monitor Performance of our application in a specific environment.

在此处输入图像描述

Refer here for more information

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM