Skip to content

Conversation

@jas88
Copy link
Owner

@jas88 jas88 commented Oct 29, 2025

Summary

Excludes the Source Generator project from Codecov coverage calculations to fix artificially low coverage reporting.

Problem

  • Source generators execute only at compile-time, not at test runtime
  • The 15 files in src/CsvHandler.SourceGenerator/ don't get runtime coverage
  • This artificially lowers the overall coverage percentage below the 80% threshold
  • Current coverage shows ~40%, but this includes untestable compile-time code

Solution

Updated codecov.yml:

  • Added src/CsvHandler.SourceGenerator/**/* to ignore list
  • Removed Source Generator from component management
  • Coverage now focuses only on runtime library code (src/CsvHandler/)

Impact

This should bring coverage metrics back to realistic levels, measuring only code that can actually be tested at runtime.

Related

Fixes coverage issues blocking PRs #21, #22, #23

jas88 added 3 commits October 28, 2025 20:17
Source generators only run at compile-time, not runtime, so they don't
get code coverage during tests. Excluding the 15 source generator files
from coverage requirements to get accurate runtime coverage metrics.

This focuses coverage on the runtime library code (src/CsvHandler) which
is what actually executes during tests and should resolve the low
coverage issue (< 40% vs 80% target).
Removed FluentAssertions dependency and replaced ~213 assertions across
6 test files with standard xUnit assertions:

- WriterTests.cs (~24 assertions)
- ParserTests.cs (~80 assertions)
- ReaderTests.cs (~14 assertions)
- PolyfillTests.cs (~30 assertions)
- AotCompatibilityTests.cs (~15 assertions)
- IntegrationTests.cs (~50 assertions)

Changes:
- Replaced .Should().BeTrue/False() with Assert.True/False()
- Replaced .Should().Be(x) with Assert.Equal(x, actual)
- Replaced .Should().NotBeNull() with Assert.NotNull()
- Replaced comparison assertions with Assert.True(condition)
- Removed FluentAssertions package reference from csproj

Benefits:
- Reduced test dependencies
- Simpler, more standard assertion style
- Smaller package footprint
Resolved conflict by keeping FluentAssertions removed (already replaced
with xUnit assertions in previous commit).

// Just verify the check doesn't throw (hardware dependent)
(isAccelerated == true || isAccelerated == false).Should().BeTrue();
Assert.True(isAccelerated == true || isAccelerated == false);

Check notice

Code scanning / CodeQL

Unnecessarily complex Boolean expression Note test

The expression 'A == true' can be simplified to 'A'.

Copilot Autofix

AI 7 days ago

The best way to fix this problem is to rewrite the assertion so that it is not needlessly complex. The original assertion is always true for Boolean values. If the intention is to verify that accessing the hardware acceleration status does not throw, no assertion is strictly necessary; the test will fail if an exception occurs. If an assertion is still desired, it can check that isAccelerated is a Boolean (which is always true in this context), or simply assert something more meaningful (e.g., Assert.True(isAccelerated == isAccelerated) or just Assert.True(true)). For demonstration and keeping the assertion, simplifying to Assert.True(true); is the least intrusive change.

Edit line 254 in tests/CsvHandler.Tests/PolyfillTests.cs:

  • Replace Assert.True(isAccelerated == true || isAccelerated == false); with Assert.True(true);.

No imports or new method definitions are required.

Suggested changeset 1
tests/CsvHandler.Tests/PolyfillTests.cs

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/tests/CsvHandler.Tests/PolyfillTests.cs b/tests/CsvHandler.Tests/PolyfillTests.cs
--- a/tests/CsvHandler.Tests/PolyfillTests.cs
+++ b/tests/CsvHandler.Tests/PolyfillTests.cs
@@ -251,7 +251,7 @@
 #endif
 
         // Just verify the check doesn't throw (hardware dependent)
-        Assert.True(isAccelerated == true || isAccelerated == false);
+        Assert.True(true);
     }
 
     #endregion
EOF
@@ -251,7 +251,7 @@
#endif

// Just verify the check doesn't throw (hardware dependent)
Assert.True(isAccelerated == true || isAccelerated == false);
Assert.True(true);
}

#endregion
Copilot is powered by AI and may make mistakes. Always verify output.

// Just verify the check doesn't throw (hardware dependent)
(isAccelerated == true || isAccelerated == false).Should().BeTrue();
Assert.True(isAccelerated == true || isAccelerated == false);

Check notice

Code scanning / CodeQL

Unnecessarily complex Boolean expression Note test

The expression 'A == false' can be simplified to '!A'.

Copilot Autofix

AI 7 days ago

To fix this problem, rewrite the unnecessarily complex Boolean comparison isAccelerated == false to use the simpler, idiomatic equivalent !isAccelerated. Specifically, in tests/CsvHandler.Tests/PolyfillTests.cs, on line 254, change:

Assert.True(isAccelerated == true || isAccelerated == false);

to:

Assert.True(isAccelerated || !isAccelerated);

No additional imports, method definitions, or variable definitions are required.

Suggested changeset 1
tests/CsvHandler.Tests/PolyfillTests.cs

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/tests/CsvHandler.Tests/PolyfillTests.cs b/tests/CsvHandler.Tests/PolyfillTests.cs
--- a/tests/CsvHandler.Tests/PolyfillTests.cs
+++ b/tests/CsvHandler.Tests/PolyfillTests.cs
@@ -251,7 +251,7 @@
 #endif
 
         // Just verify the check doesn't throw (hardware dependent)
-        Assert.True(isAccelerated == true || isAccelerated == false);
+        Assert.True(isAccelerated || !isAccelerated);
     }
 
     #endregion
EOF
@@ -251,7 +251,7 @@
#endif

// Just verify the check doesn't throw (hardware dependent)
Assert.True(isAccelerated == true || isAccelerated == false);
Assert.True(isAccelerated || !isAccelerated);
}

#endregion
Copilot is powered by AI and may make mistakes. Always verify output.
@codecov
Copy link

codecov bot commented Oct 29, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 24.07%. Comparing base (93551ec) to head (f991436).
⚠️ Report is 1 commits behind head on main.

❌ Your project status has failed because the head coverage (24.07%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #25   +/-   ##
=======================================
  Coverage   24.07%   24.07%           
=======================================
  Files          29       29           
  Lines        1458     1458           
  Branches      287      287           
=======================================
  Hits          351      351           
  Misses       1065     1065           
  Partials       42       42           

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 93551ec...f991436. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jas88 jas88 merged commit 71d9a67 into main Oct 29, 2025
7 of 8 checks passed
@jas88 jas88 deleted the fix/codecov-exclude-source-generator branch October 29, 2025 01:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants