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
516 stars 39 forks source link

System.IO.File.ReadAllText call "breaks" code coverage #331

Closed AdrianMatei20 closed 10 months ago

AdrianMatei20 commented 1 year ago

Installed product versions

Description

Calling System.IO.File.ReadAllText inside a test class "breaks" code coverage.

Steps to recreate

  1. Create an NUnit test project (or Class Library).
  2. Create a test.
  3. In the middle of the test add something like "string fileContent = System.IO.File.ReadAllText(pathToAnyFile);".
  4. Run all tests.
  5. Fine Code Coverage shows everything above the line as covered and everything after that line as uncovered (including any classes that are being tested).

https://github.com/FortuneN/FineCodeCoverage/assets/85348753/dd546b93-4ba5-40e3-b886-9f804e50e596

Current behavior

Fine Code Coverage stops tracking covered code after encountering a System.IO.File.ReadAllText call.

Expected behavior

System.IO.File.ReadAllText calls shouldn't be affecting the code coverage.

tonyhallett commented 1 year ago

What I expect is happening is that the test is failing when executed by FCC. ReadAllText is throwing an exception. The reason is mentioned on the readme page. If you switch to ms code coverage there will be no issues.