Skip to content

Implement end-to-end integration testing for complete workflow #222

@milliondreams

Description

@milliondreams

Problem

While individual components (executor, runner, CLI) will be implemented, we need comprehensive end-to-end integration testing to ensure the complete system works together correctly with real MCP servers.

Solution

Create end-to-end integration tests that validate the complete test harness functionality from CLI invocation through test execution to report generation.

Implementation Details

New Test Infrastructure:

1. End-to-End Integration Tests (crates/mandrel-mcp-th/tests/integration/)

/// Test complete workflow: CLI → Runner → Executor → Reports
#[tokio::test]
async fn test_complete_workflow_with_codeprism_server() {
    // 1. Start CodePrism MCP server
    // 2. Execute test via CLI
    // 3. Validate all reports generated
    // 4. Verify test results accuracy
}

/// Test with all supported YAML specification formats
#[tokio::test]
async fn test_all_specification_formats() {
    // Test comprehensive, tools, and workflow specifications
}

/// Test error handling and recovery scenarios
#[tokio::test]
async fn test_error_scenarios() {
    // Server disconnection, invalid specs, timeouts
}

2. Mock MCP Server for Testing

/// Lightweight mock MCP server for predictable testing
pub struct MockMcpServer {
    pub tools: HashMap<String, Box<dyn Fn(Value) -> Value>>,
}

impl MockMcpServer {
    /// Create server with predefined tool responses
    pub fn with_tools(tools: Vec<(&str, Box<dyn Fn(Value) -> Value>)>) -> Self
    
    /// Start server and return connection info
    pub async fn start(&self) -> Result<ServerInfo>
}

3. Test Data and Fixtures

  • Complete test specifications covering all CodePrism tools
  • Expected output samples for validation
  • Error scenario test cases
  • Performance benchmark test cases

Test Coverage Areas:

1. Component Integration

  • CLI → TestSuiteRunner integration
  • TestSuiteRunner → TestCaseExecutor integration
  • TestCaseExecutor → MCP Client integration
  • Validation Engine → Reporting integration

2. Real Server Testing

  • CodePrism MCP server integration
  • All 26 MCP tools execution and validation
  • Multi-language test specification execution
  • Performance characteristics validation

3. Error Handling

  • Server connection failures
  • Invalid YAML specifications
  • Tool execution timeouts
  • Malformed server responses
  • Network interruption recovery

4. Report Generation

  • HTML report generation and validation
  • JSON report format compliance
  • JUnit XML format compatibility
  • Markdown report readability

Dependencies:

Test Requirements:

  • Complete workflow integration tests
  • Mock server testing infrastructure
  • Real CodePrism server integration tests
  • Performance and load testing
  • Error recovery and resilience tests

Success Criteria:

  • Complete CLI workflow works end-to-end
  • All CodePrism test specifications execute successfully
  • Report generation works in all formats
  • Error handling provides useful feedback
  • Performance meets requirements (<10 seconds for comprehensive test)
  • Integration tests run reliably in CI/CD

Test Scenarios:

# 1. Basic functionality test
moth test codeprism-python-comprehensive.yaml

# 2. Full report generation test  
moth test codeprism-rust-comprehensive.yaml --output ./reports --format html

# 3. Error handling test
moth test invalid-spec.yaml  # Should show helpful error

# 4. Performance test
moth test large-specification.yaml --verbose  # Should complete in <10s

Validation:

  • Compare generated reports against expected outputs
  • Verify all test results match expected outcomes
  • Validate performance metrics are collected correctly
  • Ensure error messages are helpful and actionable

Testing:

  • Run against all CodePrism moth specifications
  • Test with various MCP server configurations
  • Validate across different environments (CI/CD, local)
  • Performance testing with large test suites

Estimated Effort:

4-6 hours

Priority:

P0 - Required to validate complete system functionality

Metadata

Metadata

Assignees

No one assigned

    Labels

    P0Critical Production Issues - Immediate Response RequiredintegrationIntegration testing and end-to-end workflowsmandrelMandrel MCP Test Harness related issuesmcp-protocolModel Context Protocol implementationtestingTesting infrastructure and test coverage

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions