Improve test quality: CareMetrics.Tests/UnitTests.cs#38
Draft
Improve test quality: CareMetrics.Tests/UnitTests.cs#38
Conversation
… tests Co-authored-by: rowantervelde <22254598+rowantervelde@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Improve test quality in CareMetrics.Tests/UnitTests.cs
Improve test quality: CareMetrics.Tests/UnitTests.cs
Mar 11, 2026
This was referenced Mar 11, 2026
This was referenced Mar 19, 2026
This was referenced Mar 26, 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.cscontained a placeholder test, a 44-line monolithic parser test that mixed concerns, and zero coverage forVektisCsvParser.ParseDirectory.Changes
Truth_IsTrue(Assert.True(true)) placeholderParser_CanParseRealVektisFileinto two focused tests:Parser_CsvHeaderHasExpectedColumns— validates CSV column contractParser_ParseFile_ReturnsNonEmptyRecords— validates parser output[Theory]edge-case tests forParseFile— no year in filename and empty file both return[]Parser_ParseDirectory_EmptyDirectory_ReturnsEmpty— first coverage forParseDirectoryFindVektisCsvFile()helper with null/empty guards to eliminate duplicated directory-walking logicService_CanLoadSampleCsv_FromConfiguration→ newVektisDataServiceIntegrationTestsclass (renamedService_LoadsRealCsvData_FromConfiguration) to separate filesystem-dependent integration tests from unit testsPath.GetRandomFileName()for temp dirs in edge-case tests to prevent parallel-execution race conditionsTest count: 22 → 25.
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 xUnit Test Quality Expert. This file contains 3[Fact]methods across 110 lines and includes a placeholder test, overly verbose integration-style assertions, and missing coverage forVektisCsvParseredge cases.Current State
CareMetrics.Tests/UnitTests.csCareMetrics.API/Services/VektisCsvParser.cs,CareMetrics.API/Services/VektisDataService.cs[Fact]/ 0[Theory]methodsTest Quality Analysis
Strengths ✅
Parser_CanParseRealVektisFileruns the actual parser against real CSV data and validates column names, counts, and decimal parsing — good end-to-end confidenceService_CanLoadSampleCsv_FromConfigurationvalidates DI wiring, multi-year loading, and a minimum record count in a single testAssert.NotNull(dir)andAssert.NotEmpty(...)instead of raw boolean checks in key placesAreas for Improvement 🎯
1. Remove placeholder
Assert.True(true)testCurrent:
Recommended: Delete
Truth_IsTrueentirely. It adds noise to the test suite and a permanently-green test gives false confidence.Why this matters: Placeholder tests inflate pass counts, hide coverage gaps, and confuse future contributors about intent.
2. Decompose the overlong
Parser_CanParseRealVektisFiletestThe test is 44 lines long and manually re-implements CSV parsing logic before calling
VektisCsvParser.ParseFile. The manual pre-validation and the parser call should live in separate, focused tests.View current test (condensed)
Recommended decomposition:
Why this matters: A single failing assertion in a 44-line test makes it hard to pinpoint the root cause. Smaller tests fail faster and point directly to the broken contract.
3. Add
[Theory]/[InlineData]forVektisCsvParseredge casesCurrently zero parameterised tests exist in this file. Several edge-case scenarios for
ParseFile/ParseDirectoryshould be parameterised: