-
Notifications
You must be signed in to change notification settings - Fork 338
Tool list testcase #873
Tool list testcase #873
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds comprehensive unit tests for the ToolsListCommand.cs
functionality, which implements the azmcp tool list
command that lists all available tools in the Azure MCP server. The tests validate various scenarios including successful execution, error handling, JSON serialization, and command structure validation.
Key changes:
- Added 10 comprehensive test methods covering normal operation, error scenarios, and edge cases
- Implemented proper mocking and service provider setup for isolated testing
- Added validation for command structure, filtering, and metadata properties
Comments suppressed due to low confidence (2)
core/tests/AzureMcp.Core.UnitTests/Areas/Tools/UnitTests/ToolsListCommandTests.cs:147
- This test assertion appears to be checking that the 'list' command is filtered out, but the logic is unclear and may not be testing the intended behavior. The test name suggests it should verify hidden commands are filtered, but this assertion doesn't clearly demonstrate what constitutes a 'hidden' command.
Assert.DoesNotContain(result, cmd => cmd.Name == "list" && cmd.Command.Contains("tool"));
core/tests/AzureMcp.Core.UnitTests/Areas/Tools/UnitTests/ToolsListCommandTests.cs:149
- This assertion is redundant as it only verifies that at least one command has a non-empty name, which is already covered by the earlier loop validation in ExecuteAsync_WithValidContext_ReturnsCommandInfoList test. This doesn't add meaningful test coverage for the hidden command filtering behavior.
Assert.Contains(result, cmd => !string.IsNullOrEmpty(cmd.Name));
core/tests/AzureMcp.Core.UnitTests/Areas/Tools/UnitTests/ToolsListCommandTests.cs
Outdated
Show resolved
Hide resolved
- Add 10 test methods covering various scenarios - Test JSON serialization, error handling, and command validation - Verify hidden command filtering and options validation - Add helper methods for test data setup
…/azure-mcp into tool_list_testcase_restore
While attempting to rebase my branch with main, I accidentally ran git push --force, which caused my original PR #796 to close. I've since addressed all the review comments. For reference and better visibility, I’m including screenshots of each comment below: ![]() ![]() ![]() ![]()
![]() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes look good. You'll have to update the .vscode/cspell.json
file to include the words flagged by the pipeline. Alternatively, you can remove those words from the PR. Up to you :)
* Unit testcase Tool List * Cleaned the code * Mocked a testcase properly * Add comprehensive unit tests for ToolsListCommand - Add 10 test methods covering various scenarios - Test JSON serialization, error handling, and command validation - Verify hidden command filtering and options validation - Add helper methods for test data setup * Added AppConfig to testcase and reviewed other comments * Fixed a testcase check * Fixed spelling error
What does this PR do?
Added Unit testcases for the ToolListCommand.cs file.
Command- azmcp tool list
Function: List all available tools in the Azure MCP server.
GitHub issue number?
[Link to the GitHub issue this PR addresses]
Pre-merge Checklist
CHANGELOG.md
for product changes (features, bug fixes, UI/UX, updated dependencies
).\eng\common\spelling\Invoke-Cspell.ps1
README.md
documentation/docs/azmcp-commands.md
/e2eTests/e2eTestPrompts.md
crypto mining, spam, data exfiltration, etc.
)/azp run azure - mcp
to run Live Test Pipeline