Improve test quality: CareMetrics.Tests/UnitTests.cs#33
Draft
Improve test quality: CareMetrics.Tests/UnitTests.cs#33
Conversation
Co-authored-by: rowantervelde <22254598+rowantervelde@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Improve test quality in CareMetrics.Tests
Improve test quality: CareMetrics.Tests/UnitTests.cs
Mar 8, 2026
This was referenced Mar 8, 2026
This was referenced Mar 15, 2026
This was referenced Mar 22, 2026
4 tasks
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 test that re-implemented CSV parsing internals instead of asserting on parser output, and no coverage ofVektisCsvParser.ParseDirectory.Changes
Truth_IsTrue(Assert.True(true)) placeholderGetSolutionRoot()private helper — eliminates the copy-pasted directory-walk from two test methodsParser_CanParseRealVektisFile— replaced manual CSV header/column inspection with assertions on the returnedVektisRecordlist:[Theory]/[InlineData]test covering year extraction for 2020, 2021, and 2023 filesParseDirectory_HappyPath_ReturnsRecords— asserts non-empty results spanning multiple yearsParseDirectory_EmptyDirectory_ReturnsEmpty— covers the empty-dir edge case using a temp directoryOriginal 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.cswas selected for quality improvement by the 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[Fact]/ 0[Theory]methodsVektisCsvParser.ParseDirectory(not tested at all)Test Quality Analysis
Strengths ✅
Parser_CanParseRealVektisFileandService_CanLoadSampleCsv_FromConfigurationexercise the system against actual CSV files on disk, which catches real-world parsing issues.$"Parser produced 0 records from {Path.GetFileName(targetFile)}") that aid debugging on CI.Areas for Improvement 🎯
1. Remove placeholder test — Assert.True(true)
Current code (line 13-16):
Problem: This test asserts nothing meaningful. It will always pass regardless of any code change, providing a false sense of test coverage and inflating the test count.
Recommended change: Delete this method entirely. If a "smoke test" is still desired, replace it with something that actually verifies a real behaviour:
Why this matters: Placeholder tests mask coverage gaps and clutter test output. xUnit has no concept of "pending" tests — a passing
Assert.True(true)is silent noise.2. Extract shared helper — duplicate solution-root discovery
Problem: The same 4-line
AppContext.BaseDirectory→ directory-walk pattern appears verbatim in bothParser_CanParseRealVektisFile(lines 21–27) andService_CanLoadSampleCsv_FromConfiguration(lines 67–73). Any change to the discovery logic must be made in two places.Recommended change: Extract a private helper or use a shared fixture:
Why this matters: DRY reduces the blast radius of future changes (e.g., if the solution file is renamed or the layout changes).
3. Parser_CanParseRealVektisFile re-implements parser internals
Problem: The test manually reads headers and data lines (lines 32–62) to verify assumptions that are already encoded in
VektisCsvParser.ParseFileitself. This makes the test:Recommended refactor: Trust
ParseFileto handle the CSV; test only its output:The manual header-sniffing block (bytes, hex,
decimal.TryParse) is di...🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.