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
| Name | Required | Description | Default |
|---|---|---|---|
| feature | Yes | The feature or function to test | |
| type | No | Type of tests |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"feature": {
"description": "The feature or function to test",
"type": "string"
},
"type": {
"description": "Type of tests",
"enum": [
"unit",
"integration",
"e2e",
"all"
],
"type": "string"
}
},
"required": [
"feature"
],
"type": "object"
}
Implementation Reference
- src/tools/cognitive.ts:529-594 (handler)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 }] }; }
- src/tools/cognitive.ts:520-527 (schema)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 }],