generate_test_report
Generate test execution reports in JSON or HTML format from JIRA Zephyr test cycles to track testing progress and results.
Instructions
Generate test execution report
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"cycleId": "<cycleId>"
},
"name": "generate_test_report"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cycleId | Yes | Test cycle ID | |
| format | No | Report format (default: JSON) |
Implementation Reference
- src/tools/test-execution.ts:133-165 (handler)Main handler function for generate_test_report tool. Validates input, calls Zephyr client to get report data, generates HTML if requested, and returns formatted report.
export const generateTestReport = async (input: GenerateTestReportInput) => { const validatedInput = generateTestReportSchema.parse(input); try { const report = await getZephyrClient().generateTestReport(validatedInput.cycleId); if (validatedInput.format === 'HTML') { const htmlReport = generateHtmlReport(report); return { success: true, data: { format: 'HTML', content: htmlReport, generatedOn: report.generatedOn, }, }; } return { success: true, data: { format: 'JSON', content: report, generatedOn: report.generatedOn, }, }; } catch (error: any) { return { success: false, error: error.response?.data?.message || error.message, }; } }; - src/tools/test-execution.ts:167-232 (helper)Helper function to generate HTML report from the test execution data.
const generateHtmlReport = (report: any) => { return ` <!DOCTYPE html> <html> <head> <title>Test Execution Report - ${report.cycleName}</title> <style> body { font-family: Arial, sans-serif; margin: 20px; } .header { background-color: #f5f5f5; padding: 20px; border-radius: 5px; } .summary { display: flex; gap: 20px; margin: 20px 0; } .metric { background-color: #e8f4f8; padding: 15px; border-radius: 5px; text-align: center; } .metric h3 { margin: 0 0 10px 0; } .metric .value { font-size: 24px; font-weight: bold; } .executions { margin-top: 30px; } .execution { padding: 10px; border-left: 4px solid #ddd; margin: 10px 0; } .execution.pass { border-left-color: #4caf50; } .execution.fail { border-left-color: #f44336; } .execution.blocked { border-left-color: #ff9800; } .execution.progress { border-left-color: #2196f3; } </style> </head> <body> <div class="header"> <h1>Test Execution Report</h1> <h2>${report.cycleName}</h2> <p>Project: ${report.projectKey}</p> <p>Generated: ${new Date(report.generatedOn).toLocaleString()}</p> </div> <div class="summary"> <div class="metric"> <h3>Total Tests</h3> <div class="value">${report.summary.total}</div> </div> <div class="metric"> <h3>Passed</h3> <div class="value">${report.summary.passed}</div> </div> <div class="metric"> <h3>Failed</h3> <div class="value">${report.summary.failed}</div> </div> <div class="metric"> <h3>Blocked</h3> <div class="value">${report.summary.blocked}</div> </div> <div class="metric"> <h3>Pass Rate</h3> <div class="value">${Math.round(report.summary.passRate)}%</div> </div> </div> <div class="executions"> <h3>Test Executions</h3> ${report.executions.map((exec: any) => ` <div class="execution ${exec.status.toLowerCase()}"> <strong>${exec.key}</strong> - ${exec.status} ${exec.comment ? `<p>${exec.comment}</p>` : ''} ${exec.defects.length > 0 ? `<p>Defects: ${exec.defects.map((d: any) => d.key).join(', ')}</p>` : ''} </div> `).join('')} </div> </body> </html> `; }; - src/utils/validation.ts:54-57 (schema)Zod schema for validating GenerateTestReportInput, used in the handler and MCP dispatch.
export const generateTestReportSchema = z.object({ cycleId: z.string().min(1, 'Cycle ID is required'), format: z.enum(['JSON', 'HTML']).default('JSON'), }); - src/index.ts:172-182 (registration)Tool registration in the TOOLS array, defining name, description, and inputSchema for MCP.
name: 'generate_test_report', description: 'Generate test execution report', inputSchema: { type: 'object', properties: { cycleId: { type: 'string', description: 'Test cycle ID' }, format: { type: 'string', enum: ['JSON', 'HTML'], description: 'Report format (default: JSON)' }, }, required: ['cycleId'], }, }, - src/index.ts:425-435 (registration)Dispatch handler in the MCP CallToolRequest switch statement that invokes the generateTestReport function.
case 'generate_test_report': { const validatedArgs = validateInput<GenerateTestReportInput>(generateTestReportSchema, args, 'generate_test_report'); return { content: [ { type: 'text', text: JSON.stringify(await generateTestReport(validatedArgs), null, 2), }, ], }; }