Improve test quality: CareMetrics.Tests/UnitTests.cs#48
Draft
Improve test quality: CareMetrics.Tests/UnitTests.cs#48
Conversation
Co-authored-by: rowantervelde <22254598+rowantervelde@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] [xunit-expert] Improve test quality for CareMetrics.Tests
Improve test quality: CareMetrics.Tests/UnitTests.cs
Mar 17, 2026
This was referenced Mar 17, 2026
This was referenced Mar 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
UnitTests.cshad a placeholder test, duplicated solution-root discovery logic, a monolithic integration test, and no coverage forParseDirectoryorParseFileedge cases.Changes
Truth_IsTrue()placeholderSolutionRootFixture— solution-root walking moved from two test methods into a sharedIClassFixture<SolutionRootFixture>, injected via constructorParser_CanParseRealVektisFileinto three focused tests:HasExpectedHeaders,InsuredColumnParsesAsPositiveDecimal,ProducesRecords[Theory]/[InlineData]edge cases forParseFile— no year in filename, empty file content, header-only CSV; each runs in an isolated temp directoryParseDirectorytests — happy path against real data dir, and empty directory → empty listreader.Close()(superseded byusing)UnitTest1.csTest count: 22 → 28, all passing.
Original prompt
This section details on the original issue you should resolve
<issue_title>[xunit-expert] Improve Test Quality: CareMetrics.Tests/UnitTests.cs</issue_title>
<issue_description>The test file
CareMetrics.Tests/UnitTests.cshas been selected for quality improvement by the daily xUnit Test Quality Expert. This issue provides specific, actionable recommendations to enhance test quality, coverage, and maintainability using xUnit best practices for .NET.Current State
CareMetrics.Tests/UnitTests.csCareMetrics.API/Services/VektisCsvParser.cs,CareMetrics.API/Services/VektisDataService.cs[Fact]methods (0[Theory])Test Quality Analysis
Strengths ✅
Parser_CanParseRealVektisFilevalidates actual CSV file structure (header columns, column count, decimal parsing) against a real Vektis data file, making it a high-value regression guard.Service_CanLoadSampleCsv_FromConfigurationexercises the fullServiceCollection→IVektisDataServicewiring, ensuring the service can be resolved with real configuration.$"Expected >10k records, got {all.Count}") which aids debugging in CI.Areas for Improvement 🎯
1. Placeholder Test — Remove
Truth_IsTrueCurrent Issue:
Assert.True(true)always passes regardless of any code change. It adds noise to test output and masks the true coverage picture.Recommended Fix:
Why this matters: Placeholder tests are a common smell that erodes trust in the test suite. Test runners show a false "green" even when real tests are broken.
2. Duplicated Solution-Root Discovery Logic
Current Issue:
Both
Parser_CanParseRealVektisFileandService_CanLoadSampleCsv_FromConfigurationcontain an identical 4-line loop to walk up the directory tree:Recommended Fix:
Extract to a shared fixture or a static helper method:
Why this matters: DRY principle — if the detection logic ever needs to change (e.g., a different solution file name), it currently needs updating in two places.
3. Missing Tests for
VektisCsvParser.ParseDirectory()Current Issue:
VektisCsvParserexposes two public static methods:ParseFile(string path)— ✅ tested (indirectly) inParser_CanParseRealVektisFileParseDirectory(string directory)— ❌ zero test coverageParseDirectoryhas its own logic (iterates files, swallows individual exceptions) that is not exercised at all.Recommended Tests: