Increase code coverage in unit test pipeline#3703
Conversation
There was a problem hiding this comment.
Pull request overview
This PR increases unit-test/branch coverage by adding database-free tests for pure-logic helpers, config JSON converters, and MCP tooling validation paths, without changing product/runtime behavior.
Changes:
- Adds unit tests for multiple config JSON converters (embeddings, cache, compression, Key Vault, DML tools, bool parsing, etc.).
- Adds unit tests for core helper utilities/parsers (TypeHelper, enum parsing, JSON reader extensions, entity source parsing, merge-json).
- Adds non-DB unit tests for MCP utilities and early-return validation/error paths in built-in DML tools.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/Service.Tests/UnitTests/Utf8JsonReaderExtensionsTests.cs | Covers string/null/non-string token handling for Utf8JsonReaderExtensions.DeserializeString. |
| src/Service.Tests/UnitTests/TypeHelperTests.cs | Exercises TypeHelper type mappings and GraphQL value-node conversions. |
| src/Service.Tests/UnitTests/RuntimeCacheOptionsConverterTests.cs | Verifies runtime cache (L1/L2) JSON read/write behavior and validation. |
| src/Service.Tests/UnitTests/ProductInfoTests.cs | Tests ProductInfo version formatting and user-agent env-var behavior. |
| src/Service.Tests/UnitTests/MergeJsonProviderTests.cs | Tests JSON merge semantics for objects/arrays/type mismatches/null overrides. |
| src/Service.Tests/UnitTests/HttpStatusCodeExtensionsTests.cs | Validates HttpStatusCodeExtensions.IsClientError classification. |
| src/Service.Tests/UnitTests/EnumExtensionsTests.cs | Tests enum parsing incl. EnumMember values and error messaging. |
| src/Service.Tests/UnitTests/EntitySourceNamesParserTests.cs | Covers parsing/validation for schema.table inputs with bracket rules. |
| src/Service.Tests/UnitTests/EmbeddingsOptionsConverterTests.cs | Tests embeddings options converter read/write, defaults, and invalid inputs. |
| src/Service.Tests/UnitTests/EmbeddingsEndpointOptionsTests.cs | Verifies embeddings endpoint role-resolution and role-check logic. |
| src/Service.Tests/UnitTests/DmlToolsConfigConverterTests.cs | Tests boolean/object forms for MCP DML tool configuration conversion. |
| src/Service.Tests/UnitTests/DeserializationVariableReplacementSettingsTests.cs | Covers env-var replacement and local @akv file resolution logic. |
| src/Service.Tests/UnitTests/CompressionOptionsConverterTests.cs | Tests compression options JSON read/write, defaults, and invalid values. |
| src/Service.Tests/UnitTests/BoolJsonConverterTests.cs | Covers bool converter parsing of string/number representations and serialization. |
| src/Service.Tests/UnitTests/AzureKeyVaultOptionsConverterTests.cs | Tests AKV options converter behavior incl. retry policy and validation. |
| src/Service.Tests/UnitTests/AKVRetryPolicyOptionsConverterTests.cs | Tests AKV retry policy converter defaults, validation, and serialization. |
| src/Service.Tests/Mcp/McpTelemetryHelperTests.cs | Tests MCP telemetry helper operation inference and exception→code mapping/wrapper behavior. |
| src/Service.Tests/Mcp/McpResponseBuilderTests.cs | Tests MCP response builder success/error payloads and IActionResult JSON extraction. |
| src/Service.Tests/Mcp/McpJsonHelperTests.cs | Tests JSON value conversion and engine-result extraction helpers. |
| src/Service.Tests/Mcp/McpErrorHelpersTests.cs | Verifies standardized MCP error response shapes/messages. |
| src/Service.Tests/Mcp/McpAuthorizationHelperTests.cs | Tests authorization helper behavior with mocked authorization resolver/HTTP context. |
| src/Service.Tests/Mcp/McpArgumentParserTests.cs | Tests MCP argument parsing/validation for built-in tools and execute parameters. |
| src/Service.Tests/Mcp/BuiltInDmlToolValidationTests.cs | Adds non-DB tests for built-in DML tool early validation/tool-disabled/metadata-failure branches. |
Duplicates the existing EntitySourceNamesParserUnitTests, which already covers ParseSchemaAndTable comprehensively.
…b.com/Azure/data-api-builder into dev/aaronburtle/improve-code-coverage
|
@copilot can you review this again please, new tests have been added for additional coverage in the unit test pipeline. |
Reviewed the new tests. Build succeeds with 0 errors/warnings and all 151 new tests pass locally. A few observations on the additions:
No issues found — the tests are well-structured and appropriate for a coverage-improvement PR. |
|
@copilot So now that we are considering looking at the union of all of the pipelines in order to calculate the real code coverage, from that position, did our changes to the unit test add any redundant tests or are the increased branching exclusive to the unit test pipeline? |
Good question. Looking at the union of all pipeline coverage, the new tests are almost entirely exclusive — here's the breakdown: How the pipelines partition tests: Code-path coverage — likely exclusive to the unit test pipeline:
Code-path coverage — some overlap with integration tests possible: Bottom line: When taking the union, the bulk of the new branch coverage is net-new (error paths, edge cases, and configurations that integration tests are not designed to exercise). The small amount of potential overlap is in utility function happy paths, not the targeted negative/edge-case branches the PR was designed to improve. |
Why make this change?
Related to: #3648
Closes #3717
What is this change?
Improves branch coverage by adding fast, database-free unit tests for pure-logic classes that were previously at 0% or very low coverage. No product/runtime behavior is changed.
Adds ~300 unit test methods (500+ cases including
[DataRow]variations) across 35 files, all running in the existing unit-test jobEmbeddingsOptions,DmlToolsConfig,AKVRetryPolicy,AzureKeyVault,Compression,Bool,RuntimeCache/Level2converters;EmbeddingsEndpointOptionsrole resolution;DeserializationVariableReplacementSettings(env + local@akvfile resolution).create/read/update/delete_recordtools (tool-disabled, invalid args, metadata failures);McpArgumentParser,McpJsonHelper,McpResponseBuilder,McpErrorHelpers,McpAuthorizationHelper,McpMetadataHelper, andMcpTelemetryHelper.TypeHelper,EnumExtensions,Utf8JsonReaderExtensions,HttpStatusCodeExtensions,ProductInfo, andMergeJsonProvider.GraphQLNaming,GraphQLUtils,GraphQLStoredProcedureBuilderHelpers,SchemaConvertertype mapping, andEdmModelBuilder.OpenApiDocumentor, andRequestValidator(static + instance) paths.RuntimeConfigValidatorandRuntimeConfigProviderlogic.SqlPaginationUtilandSqlResponseHelpers(mutation) paths.How was this tested?
Sample Request(s)
N/A