I am trying to get code coverage metrics for an ASP.NET REST service (that uses a global.asax file) running in IIS. I have followed the following basic steps:
- Set environment variable using "VSPerfClrEnv /globaltraceon" (then reboot computer) (I have also tried /globalsampleon)
- Instrument the DLLs for code coverage using “vsinstr –coverage ” and I do this for the 5 DLLs I am interested in
- Start the profiler using "VSPerfCmd /start:coverage /output:cc.coverage /CS /user:Everyone"
- Start the service in IIS 10 1703, use Task Manager to note the PID for w3wp.exe
- Attach the profiler to the service using "VSPerfCmd /attach:"
- Run tests from Visual Studio '17 Enterprise Test Explorer against the service
- Use "VSPerfCmd /detach"
- Use "VSPerfCmd /shutdown"
But then when I open the cc.coverage file that was created, only one or two of the DLLs (it's not consistent) have coverage results, and the tests absolutely would have exercised code in all 5 DLLs. Am I doing something wrong or missing a step? Thank you!