This directory contains our testing framework for the Go Development MCP Server. We use a Go-based testing approach as our primary testing methodology, which directly executes Go commands for more reliable and maintainable tests. The older PowerShell-based tests have been preserved in the legacy directory for reference purposes only but should not be used for new test development.
testing/
├── main.go # Primary Go-based test runner for execution strategies
├── direct_runner.go # Standalone direct execution strategy runner
├── hybrid_runner.go # Standalone hybrid execution strategy runner
├── MIGRATION_STATUS.md # Migration progress tracking (currently 60% complete)
├── legacy/ # Legacy PowerShell test scripts (for reference only)
│ ├── basic/ # Legacy basic test scripts
│ ├── core/ # Legacy core functionality test scripts
│ ├── strategies/ # Legacy execution strategy test scripts
│ └── utils/ # Legacy shared utility functions
├── GETTING_STARTED.md # Quick reference guide
└── README.md # This documentation file
We use a modern Go-based testing approach that offers several advantages:
-
Main Test Runner (
main.go)- Primary entry point for running all tests
- Uses direct Go command execution without handlers
- Simplified error handling and more predictable behavior
- Runs with
go run main.goorgo run main.go -type=direct|hybrid|both
-
Standalone Strategy Runners
direct_runner.go: Tests direct code execution strategyhybrid_runner.go: Tests hybrid execution with project path and code- Both use build tags for selective compilation
The Go-based tests execute Go commands directly using os/exec rather than going through handlers:
cmd := exec.Command("go", "run", mainGoPath)
output, err := cmd.CombinedOutput()This approach eliminates dependencies on external packages and context parameters, resulting in simpler and more maintainable code.
Currently, approximately 60% of our tests have been migrated to the Go-based approach:
- ✅ Core tool functionality (run, build) - Complete
- ✅ Execution strategies - Complete
- ✅ Input handling - Complete
- 🔄 Integration between components - In Progress
- ❌ Mock server for E2E tests - Not Started
- ❌ API boundary testing - Not Started
For a detailed overview of the migration progress, see MIGRATION_STATUS.md.
Our testing approach simulates real-world interactions with the server, focusing on:
-
Testing all input modes:
- Code-only: When only inline code is provided
- Project path-only: When only a directory path is provided
- Hybrid: When both code and project path are provided
-
Testing all server tools:
go_build: Building Go codego_run: Running Go codego_fmt: Formatting Go codego_test: Running tests for Go codego_mod: Managing Go modulesgo_analyze: Analyzing Go code for issues
-
Verifying the Hybrid Strategy: The hybrid execution strategy combines:
- Project structure and dependencies from the
project_path - Modified code from the
codeparameter
This strategy is critical for providing context-aware code execution while allowing modifications.
- Project structure and dependencies from the
You can run the Go-based tests directly using the Go command-line tools:
# Run the main test runner with both direct and hybrid tests
cd c:\Users\James\Documents\go-dev-mcp\scripts\testing
go run main.go
# Run only direct execution tests
go run main.go -type=direct
# Run only hybrid execution tests
go run main.go -type=hybridFor specific tests with build tags:
# Run direct execution tests with the direct_runner
cd c:\Users\James\Documents\go-dev-mcp\scripts\testing
go run -tags=direct_test direct_runner.go
# Run hybrid execution tests with the hybrid_runner
go run -tags=hybrid_test hybrid_runner.goWe also provide a PowerShell script to run the Go tests with additional options:
# Run Go tests with verbose output
.\run_go_tests.ps1 -Verbose
# Run Go tests with race detection
.\run_go_tests.ps1 -Race
# Run Go tests with coverage
.\run_go_tests.ps1 -CoverFor more advanced testing with coverage reports:
# Generate coverage report
.\run_tests_with_coverage.ps1Our testing approach simulates real-world interactions with the server, focusing on:
-
Testing all input modes:
- Code-only: When only inline code is provided
- Project path-only: When only a directory path is provided
- Hybrid: When both code and project path are provided
-
Testing all server tools:
go_build: Building Go codego_run: Running Go codego_fmt: Formatting Go codego_test: Running tests for Go codego_mod: Managing Go modulesgo_analyze: Analyzing Go code for issues
-
Verifying the Hybrid Strategy: The hybrid execution strategy combines:
- Project structure and dependencies from the
project_path - Modified code from the
codeparameter
This strategy is critical for providing context-aware code execution while allowing modifications.
- Project structure and dependencies from the
IMPORTANT: The following sections describe our legacy PowerShell testing approach. These scripts are kept for reference purposes only and should not be used for new test development. All new tests should use the Go-based approach described above.
The legacy run_tests.ps1 script provides a way to run legacy PowerShell tests by category:
# Run all tests
.\legacy\run_tests.ps1 -TestType all
# Run only basic tests
.\legacy\run_tests.ps1 -TestType basic
# Run only core tests
.\legacy\run_tests.ps1 -TestType core
# Run only strategy tests
.\legacy\run_tests.ps1 -TestType strategiesAdditional parameters:
-VerboseOutput: Show detailed test information-KeepTestDirs: Keep temporary test directories for inspection-ServerExecutable <path>: Specify a custom server executable path
A comprehensive legacy test suite that tests all six tools provided by the Go Development MCP Server with all applicable input modes.
Usage:
.\legacy\core\all_tools_test.ps1 [-ServerExecutable <path>] [-KeepTestDirs] [-TestDir <path>] [-Verbose]Parameters:
-ServerExecutable: Path to the MCP server executable (default: "....\build\server.exe")-KeepTestDirs: If specified, test directories will not be deleted after testing-TestDir: Custom directory to use for test files-Verbose: Show detailed test information
An end-to-end legacy test script that verifies the server works correctly across multiple test cases.
Usage:
.\legacy\core\e2e_test.ps1 [-ServerUrl <url>] [-TempDir <path>] [-KeepTempFiles] [-Verbose]Parameters:
-ServerUrl: URL of the running server (default: "http://localhost:8080")-TempDir: Custom directory to use for test files-KeepTempFiles: If specified, temporary files will not be deleted after the test-Verbose: Show detailed test information
A detailed legacy test focused specifically on the hybrid execution strategy, verifying that modified code is correctly applied while maintaining project context.
Usage:
.\legacy\strategies\hybrid_strategy_test.ps1 [-ServerExecutable <path>] [-TestDir <path>] [-KeepTestDirs] [-Verbose]Parameters:
-ServerExecutable: Path to the MCP server executable (default: "....\build\server.exe")-TestDir: Base directory for test files-KeepTestDirs: If specified, test directories won't be deleted after the test-Verbose: Show detailed step-by-step execution information
This script creates test projects with varying complexity, applies code modifications, and verifies the hybrid strategy correctly combines project context with modified code.
A CLI-focused legacy test for the hybrid execution strategy, calling the server executable directly.
A simplified legacy test for verifying hybrid strategy functionality without requiring the server to be running.
A minimal legacy test script that was formerly used as a starting point for quick tests or as a template for new test scripts.
Legacy shared utility functions for PowerShell testing scripts. This file contains functions for:
- Formatting and displaying test results
- Creating test projects with various configurations
- Running Go commands and capturing their output
- Validating test results with custom assertions
Legacy Go packages for testing the direct and hybrid execution strategies. These files have been updated to use direct Go command execution instead of the handler-based approach, preserving backward compatibility while eliminating dependencies on missing packages.
A simple entry point for running legacy tests that use the direct and hybrid execution strategies without requiring the handlers package.
REMINDER: Legacy tests are maintained for reference only and should not be used for new test development.
For a quick sanity check with legacy tests:
cd c:\Users\James\Documents\go-dev-mcp\scripts\testing
.\legacy\basic\simple_test.ps1To run comprehensive legacy tests with all tools and input modes:
cd c:\Users\James\Documents\go-dev-mcp\scripts\testing
.\legacy\core\all_tools_test.ps1 -VerboseTo run legacy tests for the hybrid execution strategy specifically:
cd c:\Users\James\Documents\go-dev-mcp\scripts\testing
.\legacy\strategies\hybrid_strategy_test.ps1 -VerboseThe Go and legacy tests output results with color-coded status indicators:
- ✅ PASS: Test completed successfully (green)
- ❌ FAIL: Test failed with details about the failure (red)
- ℹ️ INFO: Informational messages (white or cyan)
Each test provides timing information and a summary of passed and failed tests at the end.
To add a new Go-based test:
- Follow the patterns in
main.go,direct_runner.go, orhybrid_runner.go - Use the direct execution approach with
os/execto run Go commands - Ensure your test covers specific scenarios or edge cases
Note: All new tests should be implemented using Go, not PowerShell.
- Go 1.16 or newer (primary requirement)
- Go Development MCP Server (executable available in the build directory)
- PowerShell 5.1 or newer (only required for legacy tests)
If Go-based tests fail:
- Check that the server executable path is correct
- Verify that Go is properly installed and in your PATH
- Check for any required dependencies
- Use the
-vflag withgo runfor more verbose output - Inspect test output for specific error messages
For legacy PowerShell tests:
- Use the
-VerboseOutputflag for more detailed output - Use the
-KeepTestDirsflag to preserve test directories for inspection
- Restructured README to prioritize Go-based testing
- Moved PowerShell test documentation to legacy section
- Clarified that PowerShell tests are maintained for reference only
- Aligned documentation with current testing practices
- Removed dependency on handlers package and context parameters
- Moved all PowerShell tests and
test_utils.ps1to the legacy directory - Updated standalone test files to use direct Go command execution
- Eliminated all dependencies on old utility functions
- Replaced MCP handler-based execution with direct Go command execution
- Implemented simplified tool matching function directly in middleware
- Removed context usage from test runner for simplicity
- Built project with zero compilation errors
- Maintained backward compatibility for legacy tests
- Ensured all test files follow the same pattern of direct command execution
- Simplified code structure by removing unnecessary abstractions
- Enhanced maintainability through reduced complexity
- Fixed test result counting in legacy scripts
- Added consistent exit code handling in all test scripts
- Proper scoping for test results collections
- Added server availability checking to legacy E2E tests
- Implemented file locking protection with retries
- Improved cleanup procedures with garbage collection
For more information on the Go Development MCP Server, refer to the main README.md.