Improve code coverage for System.Text.Json with targeted unit tests#120731
Improve code coverage for System.Text.Json with targeted unit tests#120731stephentoub merged 24 commits intomainfrom
Conversation
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
|
@copilot, please mark the DeepEquals_TooDeepJsonDocument_ThrowsInsufficientExecutionStackException test as [Outerloop] and try again, following my original instructions. |
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Done. Marked the test as [OuterLoop] and reverted the other test changes that had incorrect assertions. All tests now pass. Changes committed in edead34. |
|
…Deserialize from Span Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Working on it:
Next steps: Will re-run coverage analysis and continue adding tests for remaining uncovered areas. Changes committed in eace0c3. |
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
|
@copilot, please keep iterating: run coverage, add more tests to fill gaps, re-run coverage, add more tests to fill gaps, etc. Please try to get line and branch coverage to greater than 95%. |
…th JsonTypeInfo Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
…alize methods Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Continuing iterations: Current Progress:
Tests Added:
Next Steps to reach >95%:
Continuing to add more tests... |
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/DomTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Text.Json/tests/System.Text.Json.Tests/JsonNode/JsonValueTests.cs
Outdated
Show resolved
Hide resolved
|
@copilot, please address the feedback from @eiriktsarpalis |
…o avoid cache recreation Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Fixed in commit 0c7a2e5db. Replaced all instances of creating new JsonSerializerOptions with TypeInfoResolver with JsonSerializerOptions.Default to avoid wasteful cache recreation. |
src/libraries/System.Text.Json/tests/System.Text.Json.Tests/JsonNode/JsonValueTests.cs
Outdated
Show resolved
Hide resolved
…ons.Default Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/DomTests.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Summary
Through systematic iterations, this PR improved System.Text.Json coverage from 93.73% to 94.27% (+0.54%) by adding 136 targeted unit tests covering previously untested API surfaces including JsonSerializer methods with JsonTypeInfo/JsonSerializerContext, multi-segment Utf8JsonReader scenarios, JsonWriter formatting options, JsonNode operations, JsonNamingPolicy variants, and collection serialization.
Remaining gaps to reach 95% (~215 lines) consist primarily of complex Utf8JsonReader edge cases requiring specialized buffer setups, ThrowHelper exception paths, and F# converter infrastructure.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.