Skip to content

Enable code coverage during testing #1614

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sharwell opened this issue Feb 25, 2018 · 7 comments
Closed

Enable code coverage during testing #1614

sharwell opened this issue Feb 25, 2018 · 7 comments

Comments

@sharwell
Copy link
Contributor

Currently the test script does not run the tests with code coverage enabled. Several steps are required to enable code coverage collection:

Ensure Windows PDBs are available for OpenCover

  1. Extract embedded PDBs to portable PDBs (where applicable)
  2. Convert portable PDBs to Windows PDBs
  3. Delete the original portable PDBs
  4. Copy the dll or exe to the directory containing symbols

The following sequence applies this to all assemblies in a folder (e.g. the folder containing a unit test output):
https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/c7254023938e4e6cc5bb03caf6da0ba814845203/build/opencover-report.ps1#L54-L95

Wrap the unit test call with OpenCover.Console

https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/c7254023938e4e6cc5bb03caf6da0ba814845203/build/opencover-report.ps1#L111-L121

Prepare the results

For local builds, run ReportGenerator on the output:
https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/c7254023938e4e6cc5bb03caf6da0ba814845203/build/opencover-report.ps1#L147-L148

For CI builds, send the collection to codecov.io:
https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/c7254023938e4e6cc5bb03caf6da0ba814845203/appveyor.yml#L14

@sharwell
Copy link
Contributor Author

@tmat This is my first priority this week. At this point I have a very good understanding of how the pieces fit together (portable/embedded PDB + xunit console + OpenCover console + reporting), but very little understanding of the way roslyn-tools invokes the xunit console for testing purposes. I'm hoping you can help me incorporate each of the necessary steps above into the testing harness we use.

@tmat
Copy link
Member

tmat commented Feb 26, 2018

Why is this needed now? If anything it would be better to invest our time in helping OpenCover to support Portable PDBs.

@sharwell
Copy link
Contributor Author

@tmat That could be beneficial as well. I found in the proof of concept that the PDB conversion step wasn't quite as complex as mentioned above because the built uses embedded PDB for all binaries.

@tmat
Copy link
Member

tmat commented Feb 27, 2018

I'd love to get automatic code coverage reports. But I'm not sure if it's worth the complexity at this point. The effort spent on implementing a workaround in our repos won't help our customers. Effort spent on helping OpenCover to adopt Portable PDBs faster will help everyone.

@sharwell
Copy link
Contributor Author

@tmat fortunately, of the issues involved with getting this working, the PDBs seem like a solved problem. The toolset already included everything to make it work seamlessly. We can take a look at the couple remaining small items tomorrow. 😁

@tmat
Copy link
Member

tmat commented Feb 27, 2018

I don't think I'll have time this week to look into this.

@Evangelink
Copy link
Member

I think the ticket is no longer relevant as we can see coverage on PRs (ping @sharwell ).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants