cpp-mcp/test
hkr04 7f9862f91c zh -> en 2025-03-17 16:29:33 +08:00
..
googletest@6910c9d916 set MCP_BUILD_TESTS OFF as default 2025-03-17 15:50:12 +08:00
CMakeLists.txt mcp_stdio_client: add Windows supprt 2025-03-14 15:53:58 +08:00
README.md zh -> en 2025-03-17 16:29:33 +08:00
mcp_test.cpp fix bugs in tests 2025-03-16 01:50:33 +08:00
testcase.md test WIP 2025-03-13 00:04:18 +08:00

README.md

MCP Unit Tests

This directory contains unit tests for the Model Context Protocol (MCP) implementation, based on the 2024-11-05 specification.

Building and Running Tests

Building Tests

# Create a build directory in the project root
mkdir -p build && cd build

# Configure the project
cmake ..

# Build the project and tests
make

Running Tests

# Run all tests
make run_tests

# Or directly run the test executable
./test/mcp_tests

Running Specific Tests

To run specific tests, you can use Google Test's filtering capability:

# Run all message-related tests
./test/mcp_tests --gtest_filter=McpMessageTest.*

# Run all tool-related tests
./test/mcp_tests --gtest_filter=McpToolTest.*

# Run all resource-related tests
./test/mcp_tests --gtest_filter=McpResourceTest.*

# Run all client-related tests
./test/mcp_tests --gtest_filter=ClientTest.*

# Run all server-related tests
./test/mcp_tests --gtest_filter=ServerTest.*

Test Dependencies

Tests use the Google Test framework, which is automatically downloaded and configured during the build process.

Notes

  • Some tests require network functionality, ensure that local ports (such as 8090, 8095) are not in use
  • Client and server tests will start actual servers and clients for interaction testing
  • Resource tests will create files in a temporary directory, which will be automatically cleaned up after testing