Skip to main content
Glama

generate_tests

Generate test case suggestions for software features or functions, supporting unit, integration, and end-to-end testing types to validate code functionality.

Instructions

Generates test case suggestions for a feature or function.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
featureYesThe feature or function to test
typeNoType of tests

Implementation Reference

  • The handler function for the 'generate_tests' tool. It takes feature and type arguments, generates a markdown template with suggested test cases for unit, integration, and E2E tests based on the type, and returns it as text content.
    export function generateTestsHandler(args: any) {
        const { feature, type = "all" } = args;
    
        const tests = `# Test Cases: ${feature}
    
    ## Test Type: ${type}
    
    ---
    
    ## Unit Tests
    ${type === "unit" || type === "all" ? `
    ### Happy Path
    - [ ] Test with valid input
    - [ ] Test with typical use case
    - [ ] Test expected output format
    
    ### Edge Cases
    - [ ] Test with empty input
    - [ ] Test with null/undefined
    - [ ] Test with boundary values
    - [ ] Test with maximum values
    
    ### Error Handling
    - [ ] Test with invalid input
    - [ ] Test error messages
    - [ ] Test error recovery
    ` : "Not requested"}
    
    ## Integration Tests
    ${type === "integration" || type === "all" ? `
    ### Component Integration
    - [ ] Test with real dependencies
    - [ ] Test database interactions
    - [ ] Test API calls
    
    ### Data Flow
    - [ ] Test data transformation
    - [ ] Test state management
    - [ ] Test event handling
    ` : "Not requested"}
    
    ## E2E Tests
    ${type === "e2e" || type === "all" ? `
    ### User Flows
    - [ ] Test complete user journey
    - [ ] Test critical paths
    - [ ] Test error scenarios
    
    ### Cross-browser/Device
    - [ ] Test on multiple browsers
    - [ ] Test responsive behavior
    ` : "Not requested"}
    
    ## Test Data
    - Prepare mock data
    - Create test fixtures
    - Set up test database
    
    ## Coverage Goals
    - Aim for > 80% coverage
    - Cover all public APIs
    - Include edge cases
    `;
    
        return { content: [{ type: "text", text: tests }] };
    }
  • Zod schema definition for the 'generate_tests' tool, specifying input parameters: feature (required string) and type (optional enum: unit, integration, e2e, all).
    export const generateTestsSchema = {
        name: "generate_tests",
        description: "Generates test case suggestions for a feature or function.",
        inputSchema: z.object({
            feature: z.string().describe("The feature or function to test"),
            type: z.enum(["unit", "integration", "e2e", "all"]).optional().describe("Type of tests")
        })
    };
  • src/index.ts:86-86 (registration)
    Registration of the 'generate_tests' tool in the toolRegistry Map used by the stdio MCP server.
    ["generate_tests", { schema: generateTestsSchema, handler: generateTestsHandler }],
  • src/server.ts:96-96 (registration)
    Registration of the 'generate_tests' tool in the toolRegistry Map used by the HTTP MCP server.
    ["generate_tests", { schema: generateTestsSchema, handler: generateTestsHandler }],

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/millsydotdev/Code-MCP'

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