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
526 stars 40 forks source link

Code used in TestFixture (xUnit) is evaluated as Touched #451

Closed ViktorPlacek closed 2 months ago

ViktorPlacek commented 2 months ago

Installed product versions

Description

Before running integration tests a Fixture is used for preparing environment for running tests ([Fact]). All code from Core project called by the fixture code is evaluated (colored) as touched. I don't think it is fair to evaluate code called from fixture as tested.

Steps to recreate

  1. Create a test fixture and call some code from it
  2. Create some tests and call another code from it
  3. both code called from fixture and test is colored green as touched.

Current behavior

The code touched by a test fixture should not be treated as tested.

Expected behavior

Only the code called from [Fact] decorated method should be treated as tested.

Side note

Please, feel free to ask me for a simple example if the description is not clear enough.

tonyhallett commented 2 months ago

I don't think it is fair to evaluate code called from fixture as tested

FCC does not state that code is tested. FCC reports code coverage.

tonyhallett commented 2 months ago

If you do not want code to be included then exclude it.

ViktorPlacek commented 2 months ago

The exclusion does not work as I would expect. When I decorate a caller class by [ExcludeFromCodeCoverage] it is correctly not showing any 'touch' result, but all called methods from any method of the excluded class are touched.

tonyhallett commented 2 months ago

FCC just uses the code coverage of a provider when supplying the report and the editor marks.

Microsoft code coverage has the behaviour you mention whereas Coverlet has the behaviour that you expect. Coverlet is used for SDK style projects and OpenCover for the older project style. I do not know the behaviour of OpenCover.

So you can have the option RunMsCodeCoverage as No ( if your test project is SDK style ) or apply further attributes or use one of the other regexes to exclude the invoked code. You can also open an issue but note that FCC is using version 17.9.0 and not the current version 17.11.0.