microsoft / codecoverage

MIT License
84 stars 11 forks source link

Is dotnet-coverage able to track an IIS Service? #115

Closed MahiFaiyaz closed 2 months ago

MahiFaiyaz commented 7 months ago

While I am getting all code coverage of my .NET services, it does not seem to track any API calls made through the IIS service. Does this tool support code coverage for IIS services?

jakubch1 commented 7 months ago

It is possible. You need to do something similar to: https://github.com/microsoft/codecoverage/blob/main/samples/Calculator/scenarios/scenario10/README.md

  1. Invoke instrument command for all dlls which are part of IIS service (with some session id)
  2. Start dotnet-coverage in server mode specifying same session id as in 1.
  3. Start IIS server
  4. Run tests
  5. Stop dotnet-coverage from 2.

Instrumented dlls will be communicating with dotnet-coverage server using shared memory and pipes so you can still see some issues related to security. Try to make sure for example that both IIS server and coverage collection are running as same user.

jakubch1 commented 2 months ago

Added documentation how to get code coverage for IIS service: https://github.com/microsoft/codecoverage/tree/main/samples/VisualStudio/scenarios/scenario08#readme You can follow this example using also dotnet-coverage but dotnet-coverage doesn't support security features (AllowedUsers) so both collection and IIS service need to be executed using same user.