Comprehensive MCP tool integration tests and refactoring#3649
Conversation
- Add McpToolTestBase with shared service provider builders and assertion helpers - Add ReadRecordsToolMsSqlIntegrationTests (filter, select, orderby, first, errors) - Add CreateRecordToolMsSqlIntegrationTests (valid data, missing fields, errors) - Add UpdateRecordToolMsSqlIntegrationTests (valid update, numeric fields, errors) - Add DeleteRecordToolMsSqlIntegrationTests (create-then-delete, verify-gone) - Add AggregateRecordsToolMsSqlIntegrationTests (count, sum/avg/min/max, groupby) - Refactor ExecuteEntityToolMsSqlIntegrationTests to use McpToolTestBase - Refactor DynamicCustomToolMsSqlIntegrationTests to use McpToolTestBase - Use DataTestMethod/DataRow to collapse similar test cases
16ed93d to
2f9745e
Compare
There was a problem hiding this comment.
Pull request overview
Adds a shared McpToolTestBase to centralize MCP tool test setup and introduces/expands MsSql integration test coverage for MCP built-in tools (read, create, update, delete, aggregate), while refactoring existing MCP integration tests to reduce duplication.
Changes:
- Added
McpToolTestBasewith reusable service-provider builders and common MCP response/assertion helpers. - Added new MsSql integration tests for
ReadRecordsTool,CreateRecordTool,UpdateRecordTool,DeleteRecordTool, andAggregateRecordsTool. - Refactored existing MsSql MCP integration tests to inherit from
McpToolTestBaseand reuse shared helpers.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Service.Tests/Mcp/McpToolTestBase.cs | New shared base class providing MCP tool execution helpers and DI setup for query/mutation tools. |
| src/Service.Tests/Mcp/ReadRecordsToolMsSqlIntegrationTests.cs | New integration tests for read_records covering select/filter/orderby/first and error cases. |
| src/Service.Tests/Mcp/CreateRecordToolMsSqlIntegrationTests.cs | New integration tests for create_record covering success and validation/error scenarios. |
| src/Service.Tests/Mcp/UpdateRecordToolMsSqlIntegrationTests.cs | New integration tests for update_record covering success and error scenarios. |
| src/Service.Tests/Mcp/DeleteRecordToolMsSqlIntegrationTests.cs | New integration tests for delete_record, including delete-then-read verification. |
| src/Service.Tests/Mcp/AggregateRecordsToolMsSqlIntegrationTests.cs | New integration tests for aggregate_records including scalar aggregates, group-by, pagination, and error paths. |
| src/Service.Tests/Mcp/ExecuteEntityToolMsSqlIntegrationTests.cs | Refactor to inherit from McpToolTestBase and reuse shared helpers/service provider. |
| src/Service.Tests/Mcp/DynamicCustomToolMsSqlIntegrationTests.cs | Refactor to inherit from McpToolTestBase and reuse shared helpers/service provider. |
…g, and aggregate response parsing
|
Thanks, Souvik for this broad test coverage. I have added some comments that needs to be addressed. Also, the CosmosDB and MSSQL integration tests are failing, please take a look at that as well. |
… names in response
anushakolan
left a comment
There was a problem hiding this comment.
Thanks for addressing all the comments, Souvik!! This looks good to me.
RubenCerna2079
left a comment
There was a problem hiding this comment.
LGTM! Approving assuming comments will be resolved.
Why make this change?
Add comprehensive integration test coverage for MCP built-in tools (ReadRecords, CreateRecord, UpdateRecord, DeleteRecord, AggregateRecords) and refactor existing tests to eliminate code duplication.
What is this change?
McpToolTestBaseshared base class with reusable service provider builders and assertion helpersExecuteEntityToolMsSqlIntegrationTestsandDynamicCustomToolMsSqlIntegrationTeststo inherit from base class[DataTestMethod]/[DataRow]to collapse similar test casesHow was this tested?
Sample Request(s)
N/A - test-only change.