Repository navigation
test: cover AddVBFile, AddGlobalJson and SetRuntimeSdk guards - #262
Merged
Merged
Conversation
Mutation testing reports survivors on guard clauses that no unit test exercises: AddVBFile (empty/whitespace file name and content), ProjectFactoryExtensions.AddGlobalJson (runtimeVersion guard and the configure callback), GlobalJsonBuilder.SetRuntimeSdk (whitespace guard) and CreateAsync (cancellation check). The duplicate-file tests for SubdirectoryBuilder and TemporaryDirectoryBuilder only asserted the exception type, so the message mutants survived as well. Add the missing unit tests and assert the duplicate-file message. No production code is changed.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #262 +/- ##
=======================================
Coverage 89.69% 89.69%
=======================================
Files 31 31
Lines 728 728
Branches 85 85
=======================================
Hits 653 653
Misses 67 67
Partials 8 8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Problem
The latest mutation run on
mainreports about 11 survivors on guard clauses that are not part of the failing-test cluster (per the report; the log only carries totals: 51 survived, 40 of them only covered by failing tests). Affected spots:ProjectBuilderExtensions.AddVBFile:ThrowIfNullOrWhiteSpace(fileName)and(content)ProjectFactoryExtensions.AddGlobalJson:ThrowIfNullOrWhiteSpace(runtimeVersion)andconfigure?.Invoke(builder)GlobalJsonBuilder.SetRuntimeSdkwhitespace guard andCreateAsyncThrowIfCancellationRequestedSubdirectoryBuilder.CreateFileandTemporaryDirectoryBuilder.CreateFile(message mutated to empty)Root cause
Empty-name and empty-content tests exist only for
AddCSharpFile.AddGlobalJsonhas no unit test (only integration tests, which fail in the CI container). The duplicate-file tests assert only the exception type, not the message.Change
Test-only. New unit tests:
AddVBFilewith empty/whitespace file name and contentAddGlobalJsonwith empty/whitespace runtime version, and the configure callback (invoked once, receives aGlobalJsonBuilder) in a newProjectFactoryExtensionsTestsSetRuntimeSdkwith empty/whitespaceGlobalJsonBuilder.CreateAsyncwith a pre-cancelled token (may turn out equivalent for mutation purposes)Unit suite passes locally (378 tests, net10.0).
Before / After
Run: https://github.com/dailydevops/projectbuilders/actions/runs/40810654395 (mutation.yml dispatched on this branch) vs. the latest
mainrun.Seven mutants were killed, at the low end of the approximately 8 to 11 estimate. The remaining survivors outside the failing-test cluster are not itemised in the log, so which ones remain is not verified.
Risk / what this does not change
No production code change. The failing-test cluster (integration tests failing in the container) is untouched and still limits the achievable score.