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

Coverage incorrect when doing I/O operations #285

Closed SergioPicarra2 closed 2 years ago

SergioPicarra2 commented 2 years ago

Installed product versions

Description

Coverage does not seem to be correctly calculated when there is an IO operation taking place. It is correct up to the line of the IO operation and afterwards lines are marked as not covered

Steps to recreate

  1. Create a Unit test
  2. Read a file from file system (example var bytes = System.IO.File.ReadAllBytes("path_to_file/file.xlsx");
  3. Include any other operations after the file read (example var a = 1 + 2; var b = a + 3;)
  4. Notice the lines after the file read are marked as not covered even though the unit test ran fully.

Current behavior

Lines are being marked as not covered even though they are covered

Expected behavior

Lines should be marked as covered

Screenshot 2022-08-22 180705

tonyhallett commented 2 years ago

I suspect that what you are encountering is

https://github.com/FortuneN/FineCodeCoverage#old-style-coverage

Dlls are copied to a sub folder of project output folder which may affect your tests. The alternative is to set the option AdjacentBuildOutput to true

The tests that are passing in test explorer are actually failing when run by FCC. Please check the FCC Output Window pane for messages.

The other solution is to switch to ms code coverage which does not do any dll copying, although async methods are not properly covered until the next release.

SergioPicarra2 commented 2 years ago

Hi @tonyhallett , thanks for your quick reply. Indeed you are right, setting the AdjacentBuildOutput to true solved the issue. I didn't notice this. Thank you very much!