Skip to main content
Glama

flutter_test_suite

Execute comprehensive Flutter testing including unit, widget, and integration tests with coverage reporting to validate mobile application functionality and quality.

Instructions

Run complete test suite: unit tests, widget tests, integration tests with coverage report

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cwdYesWorking directory (Flutter project root)
coverageNoGenerate coverage report
integrationTestsNoInclude integration tests

Implementation Reference

  • Main execution logic for flutter_test_suite: composes flutter_test for unit/widget tests, runs integration tests directly, generates HTML coverage report.
    handler: async (args: any) => {
      const results = {
        unit: null as any,
        widget: null as any,
        integration: null as any,
        coverage: null as any
      };
      
      try {
        // Run unit and widget tests
        const testTool = flutterTools.get('flutter_test');
        results.unit = await testTool.handler({
          cwd: args.cwd,
          coverage: args.coverage
        });
        
        // Run integration tests if requested
        if (args.integrationTests) {
          const { stdout } = await processExecutor.execute(
            'flutter',
            ['test', 'integration_test'],
            { cwd: args.cwd }
          );
          results.integration = { success: true, data: stdout };
        }
        
        // Generate coverage report
        if (args.coverage) {
          const { stdout } = await processExecutor.execute(
            'genhtml',
            ['coverage/lcov.info', '-o', 'coverage/html'],
            { cwd: args.cwd }
          );
          results.coverage = { 
            success: true, 
            data: { 
              htmlReport: 'coverage/html/index.html',
              lcovFile: 'coverage/lcov.info'
            }
          };
        }
        
        return {
          success: true,
          data: results
        };
      } catch (error) {
        return {
          success: false,
          error: error instanceof Error ? error.message : String(error),
          data: results
        };
      }
    }
  • Input validation schema defining parameters for the flutter_test_suite tool.
    inputSchema: {
      type: 'object',
      properties: {
        cwd: {
          type: 'string',
          description: 'Working directory (Flutter project root)'
        },
        coverage: {
          type: 'boolean',
          description: 'Generate coverage report',
          default: true
        },
        integrationTests: {
          type: 'boolean',
          description: 'Include integration tests',
          default: false
        }
      },
      required: ['cwd']
    },
  • Registration of the flutter_test_suite tool in the super-tools map created by createSuperTools.
    // Flutter Test Suite - Complete testing workflow
    tools.set('flutter_test_suite', {
      name: 'flutter_test_suite', 
      description: 'Run complete test suite: unit tests, widget tests, integration tests with coverage report',
      inputSchema: {
        type: 'object',
        properties: {
          cwd: {
            type: 'string',
            description: 'Working directory (Flutter project root)'
          },
          coverage: {
            type: 'boolean',
            description: 'Generate coverage report',
            default: true
          },
          integrationTests: {
            type: 'boolean',
            description: 'Include integration tests',
            default: false
          }
        },
        required: ['cwd']
      },
      handler: async (args: any) => {
        const results = {
          unit: null as any,
          widget: null as any,
          integration: null as any,
          coverage: null as any
        };
        
        try {
          // Run unit and widget tests
          const testTool = flutterTools.get('flutter_test');
          results.unit = await testTool.handler({
            cwd: args.cwd,
            coverage: args.coverage
          });
          
          // Run integration tests if requested
          if (args.integrationTests) {
            const { stdout } = await processExecutor.execute(
              'flutter',
              ['test', 'integration_test'],
              { cwd: args.cwd }
            );
            results.integration = { success: true, data: stdout };
          }
          
          // Generate coverage report
          if (args.coverage) {
            const { stdout } = await processExecutor.execute(
              'genhtml',
              ['coverage/lcov.info', '-o', 'coverage/html'],
              { cwd: args.cwd }
            );
            results.coverage = { 
              success: true, 
              data: { 
                htmlReport: 'coverage/html/index.html',
                lcovFile: 'coverage/lcov.info'
              }
            };
          }
          
          return {
            success: true,
            data: results
          };
        } catch (error) {
          return {
            success: false,
            error: error instanceof Error ? error.message : String(error),
            data: results
          };
        }
      }
    });
  • Supporting flutter_test tool used by flutter_test_suite for running unit and widget tests.
    tools.set('flutter_test', {
      name: 'flutter_test',
      description: 'Run Flutter tests with optional coverage',
      inputSchema: {
        type: 'object',
        properties: {
          cwd: { type: 'string', minLength: 1, description: 'Working directory (Flutter project root)' },
          testFile: { type: 'string', description: 'Specific test file to run (optional)' },
          coverage: { type: 'boolean', description: 'Enable test coverage' }
        },
        required: ['cwd']
      },
      handler: async (args: any) => {
        const validation = FlutterTestSchema.safeParse(args);
        if (!validation.success) {
          throw new Error(`Invalid request: ${validation.error.message}`);
        }
    
        const { cwd, testFile, coverage = false } = validation.data;
    
        // Validate that it's a Flutter project
        await validateFlutterProject(cwd);
    
        const flutter_args = ['test'];
        
        if (testFile) {
          // Validate test file path (must be .dart file in test directory)
          if (!testFile.endsWith('.dart')) {
            throw new Error(`Test file must be a .dart file. Invalid test file: ${testFile}`);
          }
          
          // Check if test file exists
          const testFilePath = path.isAbsolute(testFile) ? testFile : path.join(cwd, testFile);
          try {
            await fs.access(testFilePath);
          } catch {
            throw new Error(`Test file not found. File does not exist: ${testFilePath}`);
          }
          
          flutter_args.push(testFile);
        }
        
        if (coverage) {
          flutter_args.push('--coverage');
        }
    
        const result = await processExecutor.execute('flutter', flutter_args, {
          cwd,
          timeout: 600000, // 10 minutes timeout for tests
        });
    
        return {
          success: true,
          data: {
            testFile: testFile || 'all tests',
            coverage,
            projectPath: cwd,
            exitCode: result.exitCode,
            output: result.stdout,
            errors: result.stderr,
            duration: result.duration,
            passed: result.exitCode === 0,
          },
        };
      }
    });
  • src/server.ts:61-71 (registration)
    Top-level registration loop that adds superTools (including flutter_test_suite) to the main MCP tools map if present in TOOL_REGISTRY.
    for (const toolName of Object.keys(TOOL_REGISTRY)) {
      if (allAvailableTools.has(toolName)) {
        tools.set(toolName, allAvailableTools.get(toolName));
      } else if (toolName === 'health_check') {
        // health_check is handled separately below
        continue;
      } else {
        // Tool is in registry but not implemented - log warning
        console.warn(`Warning: Tool '${toolName}' is in TOOL_REGISTRY but not implemented`);
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions coverage reports and test types but lacks critical details like execution time, resource requirements, output format, error handling, or whether it modifies project files. For a tool that runs comprehensive tests, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core action and lists key features without unnecessary words. Every part of the sentence contributes directly to understanding the tool's scope and capabilities.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of running a complete test suite with multiple test types and coverage, and with no annotations or output schema, the description is inadequate. It doesn't explain what the tool returns, how results are presented, or any behavioral nuances, leaving significant gaps for an AI agent to use it correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds no additional meaning about parameters beyond implying that 'coverage' and 'integrationTests' are part of the suite, which aligns with the schema. Baseline score of 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Run complete test suite') and specifies the scope ('unit tests, widget tests, integration tests with coverage report'), which distinguishes it from the sibling 'flutter_test' tool that likely runs a subset. However, it doesn't explicitly differentiate from 'flutter_test' in the description text itself, preventing a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'flutter_test' or other testing-related tools. It mentions what the tool does but offers no context about prerequisites, dependencies, or scenarios where it's preferred over simpler options.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cristianoaredes/mcp-mobile-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server