[test-improver] test: add StringComparison overload and null-handling tests for Assert.StartsWith/EndsWith#8781
Merged
Evangelink merged 1 commit intoJun 3, 2026
Conversation
…t.StartsWith/EndsWith Add 16 new tests covering previously untested code paths: - StringComparison.OrdinalIgnoreCase overloads for all four methods (StartsWith, DoesNotStartWith, EndsWith, DoesNotEndWith) - Null parameter handling (null value and null prefix/suffix) for all four methods Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds missing unit-test coverage for the StringComparison overloads (and null-parameter behavior) of MSTest’s string boundary assertions in src/TestFramework, ensuring structured failure messages and CheckParameterNotNull contracts are exercised.
Changes:
- Added
OrdinalIgnoreCasecoverage forAssert.StartsWith/Assert.EndsWithsuccess and for failure messages including thecomparison:evidence line. - Added null-parameter tests for
valueand prefix/suffix parameters acrossStartsWith,DoesNotStartWith,EndsWith, andDoesNotEndWith. - Validated expected/actual payload values for new structured-failure cases.
Show a summary per file
| File | Description |
|---|---|
| test/UnitTests/TestFramework.UnitTests/Assertions/AssertTests.StartsWithEndsWith.cs | Adds tests covering StringComparison overload behavior and null-parameter exception contracts for StartsWith/EndsWith assertions. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 1
JanKrivanek
approved these changes
Jun 3, 2026
This was referenced Jun 4, 2026
This was referenced Jun 15, 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.
🤖 Test Improver — automated AI assistant for test improvements.
Goal and Rationale
Assert.StartsWith,Assert.DoesNotStartWith,Assert.EndsWith, andAssert.DoesNotEndWitheach have two overloads: one defaulting toStringComparison.Ordinaland one accepting an explicitStringComparison. The existing tests inAssertTests.StartsWithEndsWith.csonly exercised the defaultOrdinalpath — theStringComparisonoverloads and null parameter handling were completely untested.These are real logic paths worth testing:
StringComparisonoverload is the core of case-insensitive string assertion, commonly used in multi-culture test suites.CheckParameterNotNullwhich throws a specificAssertFailedExceptionmessage — a contract worth verifying.Approach
Added 18 new tests to
AssertTests.StartsWithEndsWith.cscovering:OrdinalIgnoreCasesuccess (case mismatch / exact match passes)StartsWith× 2,DoesNotStartWith× 1,EndsWith× 2,DoesNotEndWith× 1OrdinalIgnoreCasefailure message includescomparison:value→AssertFailedExceptionAssertFailedExceptionCoverage Impact
AssertTests.StartsWithEndsWith.csAssert.StartsWith.cs/Assert.EndsWith.csStringComparisonoverloads untestedTrade-offs
Reproducibility
./build.sh --projects "$(pwd)/test/UnitTests/TestFramework.UnitTests/TestFramework.UnitTests.csproj" -testTest Status
✅ All
TestFramework.UnitTeststests pass (net8.0 and net9.0)Add this agentic workflows to your repo
To install this agentic workflow, run