xunit.analyzers icon indicating copy to clipboard operation
xunit.analyzers copied to clipboard

Add ability to view code coverage

Open jamesqo opened this issue 7 years ago • 5 comments

This PR adds the ability for users to generate and view code coverage reports for xunit.analyzers, using OpenCover and ReportGenerator. It's as easy as navigating to the repo root in a command prompt and typing view-coverage. The script will call dotnet test with OpenCover generating results.xml, then generate a report in <repo root>/reports/xunit.analyzers.tests/ and open it in the browser.

For an infrastructure PR, this contains a lot of code changes. Let me explain why:

  • OpenCover mysteriously says everything is 0% coverage when xunit.analyzers.tests targets net452. So I had to change it to target netcoreapp1.1 in order for the coverage to work.
    • This necessitated upgrading the version of Microsoft.CodeAnalysis.CSharp xunit.analyzers.tests used, so I upgraded it to the latest version both there and in xunit.analyzers.
      • This required changing xunit.analyzers to target netstandard1.3, in turn requiring xunit.analyzers.vsix to target net46.
    • Upgrading to netcoreapp1.1 also made some things not compile (e.g. needed extra GetTypeInfo() calls). It also screwed with the references in CodeAnalyzerHelper, causing all the tests to fail since typeof(object).Assembly.Location is no longer mscorlib.dll but System.Private.CoreLib.ni.dll. I had to rewrite most of the logic there.

jamesqo avatar Aug 05 '17 07:08 jamesqo

@bradwilson I've changed the test project to target netcoreapp1.1 instead of net452. This has caused CI failures because currently we use the console runner from tools/net452. I see there is an xunit.console.dll in tools/netcoreapp1.0, which I think is the solution to my problem, but there is no EXE file. Do you know how I can use it?

jamesqo avatar Aug 05 '17 07:08 jamesqo

@marcind You haven't said anything on this one. Would you be willing to merge this if I can resolve conflicts/get CI passing?

jamesqo avatar Aug 12 '17 21:08 jamesqo

Sorry, just have not had the time to look at everything. I'd like to try out what impact (if any) this change has on the development workflow. There's also a few things that concern me:

  • targeting a some other target than 452. Probably not a big deal but I haven't thought through that yet
  • upgrading some of the Roslyn dependencies. Not sure what impact that would have on The analyzers being able to run in VS 2015.
  • there's a lot of change so just need to find the time to scrutinize them

marcind avatar Aug 12 '17 22:08 marcind

@jamesqo That DLL is there for advanced users (you must know how to correctly use the undocumented dotnet exec). Instead, .NET Core users who want functionality like xunit.console should be using dotnet xunit as illustrated here: https://xunit.github.io/docs/getting-started-dotnet-core.html

bradwilson avatar Aug 13 '17 02:08 bradwilson

Apologies that this sat here for so long. I've picked up the project from Marcin, and just enabled better PR & CI builds via GitHub actions.

With the new .NET Core-based build system, is this PR still relevant? What is required to enable it in the new build system?

bradwilson avatar Dec 12 '19 18:12 bradwilson

Closing for age.

bradwilson avatar May 06 '23 21:05 bradwilson