FortuneN / FineCodeCoverage

Visualize unit test code coverage easily for free in Visual Studio Community Edition (and other editions too)
https://marketplace.visualstudio.com/items?itemName=FortuneNgwenya.FineCodeCoverage
Other
506 stars 38 forks source link

Coverage is not updated the Resharper Test Explorer is used #166

Closed StuartHemming closed 3 years ago

StuartHemming commented 3 years ago

Installed product versions

Description

Coverage is not updated the Resharper Test Explorer is used.

Steps to reproduce

  1. Install resharper
  2. Extensions | Resharper | Unit Tests | Unit Tests | Run Unit Tests
  3. View Fine Code Coverage window and nothing updates

If I run the same tests from the VS Test Explorer, it FineCodeCoverage window updates

Prodigio commented 2 years ago

@FortuneN is this even possible? To use the Resharper test runner in conjunction with FCC? It would be pretty nice!

tonyhallett commented 2 years ago

FCC uses the api of the Visual Studio Test Explorer. So it is not possible to get the exact same functionality. If Resharper can generate a code coverage report ( e.g from runsettings ) the best we can do ( unless there is an api ) is to watch for the generated cobertura file and then use that to generate the report and the coloured margin indicators.

Can Resharper generate code coverage ?

Prodigio commented 2 years ago

Thanks for your fast response!

Resharper itself doesn't generate code coverage reports. Jetbrains has a separate tool called dotCover which is doing the job. But one need a extra license for it. So my guess is, that without dotCover, Resharper resp. the test runner won't generate anything at all. But it's just a guess.

tonyhallett commented 2 years ago

Resharper does have a plugin system. The docs are incomplete though for unit testing.

This page https://www.jetbrains.com/help/resharper/sdk/DotNetCore.html#mapping-net-core-tests-to-resharper-elements mentions that they invoke dotnet test so if a plugin is able to intercept and add arguments then a coverage file could be generated. Of course this seems unlikely given the additional licensing.

If a developer shows that this is possible then FCC will look at again.

tonyhallett commented 2 years ago

It appears that Resharper supports runsettings https://www.google.com/search?q=resharper+runsettings&oq=resharper+runsettings&aqs=chrome..69i57j0i22i30l3j0i390l2.164539j0j4&client=ms-android-google&sourceid=chrome-mobile&ie=UTF-8

If you can set up runsettings with a data collector and get a cobertura file generated then let me know.

Prodigio commented 2 years ago

I'll play around with it maybe next week.

Prodigio commented 1 year ago

@tonyhallett so I finally had some time to dive into this topic.

Firstly, I never worked with .runsettings, so I'm not quite sure if I configured it correctly.

Unfortunately when running unit tests Resharper with said .runsettings file, the test explorer throws an NullReferenceException. I've submitted this to Jetbrains. Let's see what they say.

In turn, when running unit tests with MS Test Explorer, code coverage files are generated and FCC picks them up correctly. So it seems I'm on a good track?

tonyhallett commented 1 year ago

If FCC worked with the runsettings you provided but Resharper threw an exception then your support request is the appropriate action. Unfortunately I cannot view this request. Please keep FCC informed of your progress.

tonyhallett commented 1 year ago

@Prodigio Did you get a response ?

Prodigio commented 1 year ago

Hey @tonyhallett, just today they answered. They opened a RSRP-489987 and will fix it.

This is a quote from them:

Also, I would like to highlight that coverlet is not officially supported and tested, see RIDER-25214. Do not be misled by Rider issue, Rider and ReSharper shares the unit test backend. However, it does not decline the fact, that coverlet can work, just we did not focus on its compatibility from our side.

tonyhallett commented 1 year ago

Did you try runsettings configured for ms code coverage ? If you set RunMsCodeCoverage to Yes then FCC will generate a runsettings specific to ms code coverage, when you run tests from Test Explorer. You could then provide these runsettings to Resharper.

from https://resharper-support.jetbrains.com/hc/en-us/community/posts/360010414739-Runsettings-ignored-when-using-VS-NUnit-Resharper-test-runner

image

Look for \YourTest\bin\Debug\netcoreapp3.1\fine-code-coverage\coverage-tool-output YourTest-fcc-mscodecoverage-generated.runsettings

StuartHemming commented 1 year ago

Sorry, I'm out if rhe country at the moment, but, at the ladt time of checking, no On 23 Sept 2022, 13:36 +0100, Tony Hallett @.***>, wrote:

Did you try runsettings configured for ms code coverage ? If you set RunMsCodeCoverage to Yes then FCC will generate a runsettings specific to ms code coverage, when you run tests from Test Explorer. You could then provide these runsettings to Resharper. from https://resharper-support.jetbrains.com/hc/en-us/community/posts/360010414739-Runsettings-ignored-when-using-VS-NUnit-Resharper-test-runner Look for \YourTest\bin\Debug\netcoreapp3.1\fine-code-coverage\coverage-tool-output YourTest-fcc-mscodecoverage-generated.runsettings — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you modified the open/close state.Message ID: @.***>

tonyhallett commented 1 year ago

@Prodigio