Skip to content

Implement CLI test command functionality #221

@milliondreams

Description

@milliondreams

Problem

The CLI framework is in place with proper command structure, but the test command implementation is missing. Users currently see "Test functionality is not yet implemented" when trying to run tests.

Solution

Implement the test command functionality that integrates with the test suite runner to provide a complete CLI testing experience.

Implementation Details

Update Existing CLI Commands:

1. Implement Test Command Handler (crates/mandrel-mcp-th/src/cli/commands.rs)

impl Commands {
    /// Execute test command with proper error handling and output
    pub async fn execute_test(
        &self,
        spec_file: PathBuf,
        output_dir: Option<PathBuf>,
        format: Option<OutputFormat>,
        server_config: Option<PathBuf>,
    ) -> Result<()> {
        // 1. Initialize test suite runner
        // 2. Connect to MCP server
        // 3. Execute test specification
        // 4. Generate and save reports
        // 5. Display summary to user
    }
    
    /// Display test progress and real-time feedback
    fn display_test_progress(&self, result: &TestResult) {
        // Show real-time test execution progress
    }
}

2. Enhanced CLI Arguments

#[derive(Args)]
pub struct TestArgs {
    /// Path to test specification file
    pub spec_file: PathBuf,
    
    /// Output directory for test reports
    #[arg(short, long)]
    pub output: Option<PathBuf>,
    
    /// Report format (html, json, junit, markdown)
    #[arg(short, long, default_value = "html")]
    pub format: OutputFormat,
    
    /// Server configuration file
    #[arg(short, long)]
    pub server_config: Option<PathBuf>,
    
    /// Run tests in parallel
    #[arg(short, long)]
    pub parallel: bool,
    
    /// Fail fast on first error
    #[arg(long)]
    pub fail_fast: bool,
    
    /// Verbose output
    #[arg(short, long)]
    pub verbose: bool,
}

3. Enhanced Test Output and Progress

  • Real-time test progress display
  • Colored output for pass/fail status
  • Summary statistics
  • Report generation and location display

CLI Integration Flow:

  1. Parse command: moth test spec.yaml --output ./reports --format html
  2. Initialize runner: Create TestSuiteRunner with configuration
  3. Execute tests: Run test specification with progress display
  4. Generate reports: Create output in specified format and location
  5. Display summary: Show test results and report location

Dependencies:

Test Requirements:

  • Integration test with real YAML specification
  • CLI argument parsing tests
  • Error handling and user feedback tests
  • Report generation integration tests
  • Progress display tests

Success Criteria:

  • moth test spec.yaml command works end-to-end
  • Proper error messages for invalid inputs
  • Progress display during test execution
  • Report generation in specified format and location
  • Clean summary output with statistics
  • Verbose mode shows detailed test information

Usage Examples:

# Basic test execution
moth test codeprism-python-comprehensive.yaml

# With custom output and format
moth test spec.yaml --output ./reports --format json

# Parallel execution with fail-fast
moth test spec.yaml --parallel --fail-fast

# Verbose output
moth test spec.yaml --verbose

Testing:

  • Test with actual CodePrism YAML specifications
  • Verify all CLI options work correctly
  • Test error scenarios (missing files, invalid server config)
  • Validate report generation and output formatting

Estimated Effort:

2-3 hours

Priority:

P0 - Makes the CLI actually functional for users

Metadata

Metadata

Assignees

No one assigned

    Labels

    P0Critical Production Issues - Immediate Response RequiredenhancementNew feature or requestmandrelMandrel MCP Test Harness related issuestestingTesting infrastructure and test coveragetoolingDevelopment tools and scaffolding

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions