Skip to content

test(integration): raise integration coverage above 80% - #300

Merged
samtrion merged 1 commit into
mainfrom
test/improve-integration-coverage
Aug 12, 2026
Merged

test(integration): raise integration coverage above 80%#300
samtrion merged 1 commit into
mainfrom
test/improve-integration-coverage

Conversation

@samtrion

Copy link
Copy Markdown
Contributor

Summary

The integration test project only covered about 21% of lines / 22% of branches, well below the target of >80%. The unit test suite was already well above target, but the combined coverage requirement (>90%) was also at risk because of the integration project's low numbers.

Changes

Added integration tests that exercise the previously untested parts of the public API through realistic code-generation scenarios:

  • CSharpCodeBuilderTests.ConditionalApi.cs — every AppendIf/AppendLineIf overload, both the true and false branch, including the pointer-based overload
  • CSharpCodeBuilderTests.AppendVariants.cschar[], ReadOnlyMemory<char>, ReadOnlySpan<char>, and pointer-based Append sources, plus special-character handling ({, }, \n, \0)
  • CSharpCodeBuilderTests.DocumentationApi.cs — the full AppendXmlDoc* family, including null/empty inputs
  • CSharpCodeBuilderTests.FormatAndInterpolationApi.cs — all AppendFormat/AppendLineFormat overloads and the AppendInterpolated/AppendLineInterpolated interpolated string handler
  • CSharpCodeBuilderTests.ScopeAndCapacityApi.cs — nested Scope()/ScopeLine() usage, Clear(), Indent()/Intend(), EnsureCapacity()

Coverage (measured locally)

Suite Line Branch
Unit 90.4% 86.8%
Integration 88.3% 83.5%
Combined 93.6% 90.5%

All targets (>80% unit, >80% integration, >90% combined) are met.

Testing

  • dotnet test — 395 unit tests and 27 integration tests, all passing
  • Coverage collected via Microsoft.Testing.Extensions.CodeCoverage (cobertura) and merged with reportgenerator

Add integration tests covering the conditional Append/AppendLine API
(AppendIf/AppendLineIf), pointer/memory/span Append overloads, the
full AppendXmlDoc* documentation helpers, AppendFormat/AppendLineFormat
overloads, interpolated string handling, and nested Scope/ScopeLine
usage.

Line coverage for the integration suite rises from ~21% to ~88%,
branch coverage from ~22% to ~84%, bringing the combined unit +
integration coverage to ~94% line / ~91% branch.
@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.76%. Comparing base (1f0fe4d) to head (06a9894).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #300      +/-   ##
==========================================
+ Coverage   85.00%   91.76%   +6.76%     
==========================================
  Files          15       15              
  Lines         340      340              
  Branches      100      100              
==========================================
+ Hits          289      312      +23     
+ Misses         33       17      -16     
+ Partials       18       11       -7     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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

@samtrion
samtrion merged commit 757a045 into main Aug 12, 2026
12 checks passed
@samtrion
samtrion deleted the test/improve-integration-coverage branch August 12, 2026 11:30
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.

1 participant