Skip to main content
Glama

improve_test_case

Analyze test cases to identify issues and apply improvements with detailed suggestions and automatic fixes for better quality assurance.

Instructions

🔧 Analyze and improve a test case with detailed suggestions and optional automatic fixes

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
applyHighConfidenceChangesNoAutomatically apply high-confidence improvements
caseKeyYesTest case key (e.g., 'ANDROID-29')
checkpointsFilePathNoPath to custom checkpoints markdown file
formatNoOutput formatmarkdown
include_clickable_linksNoInclude clickable links to Zebrunner web UI
projectKeyYesProject key (e.g., 'android' or 'ANDROID')
rulesFilePathNoPath to custom rules markdown file

Implementation Reference

  • Primary handler function for the 'improve_test_case' MCP tool. Fetches test case from Zebrunner, validates it, applies improvements via TestCaseImprover, optionally auto-applies high-confidence changes, and returns formatted analysis with suggestions and improved test case draft.
    /** * Improve test case tool - dedicated improvement functionality */ async improveTestCase(input: z.infer<typeof ImproveTestCaseInputSchema>) { const { projectKey, caseKey, rulesFilePath, checkpointsFilePath, format, applyHighConfidenceChanges } = input; try { // Get the test case data first const testCase = await this.client.getTestCaseByKey(projectKey, caseKey); // Initialize validator with dynamic rules let validator: TestCaseValidator; if (rulesFilePath && checkpointsFilePath) { // Use custom rules from files - validate paths first try { const resolvedRulesPath = validateFilePath(rulesFilePath, process.cwd()); const resolvedCheckpointsPath = validateFilePath(checkpointsFilePath, process.cwd()); validator = await TestCaseValidator.fromMarkdownFiles(resolvedRulesPath, resolvedCheckpointsPath); } catch (error) { throw new Error(`Invalid file path provided: ${error instanceof Error ? error.message : error}`); } } else { // Use default rules, but try to load from standard files if they exist const defaultRulesPath = path.resolve(process.cwd(), 'test_case_review_rules.md'); const defaultCheckpointsPath = path.resolve(process.cwd(), 'test_case_analysis_checkpoints.md'); try { validator = await TestCaseValidator.fromMarkdownFiles(defaultRulesPath, defaultCheckpointsPath); } catch (error) { // Fall back to default rules if files don't exist validator = new TestCaseValidator(); } } // Validate the test case first const validationResult = await validator.validateTestCase(testCase); // Attempt improvement const improver = new TestCaseImprover(); const improvementResult = await improver.improveTestCase(testCase, validationResult); // Apply high-confidence changes if requested let finalTestCase = testCase; if (applyHighConfidenceChanges && improvementResult.improvedTestCase) { finalTestCase = improvementResult.improvedTestCase; } // Format the result let formattedResult: string; if (format === 'markdown') { formattedResult = this.formatImprovementResultAsMarkdown( validationResult, improvementResult, finalTestCase, applyHighConfidenceChanges ); } else if (format === 'string') { formattedResult = this.formatImprovementResultAsString( validationResult, improvementResult, finalTestCase, applyHighConfidenceChanges ); } else { formattedResult = JSON.stringify({ validation: validationResult, improvement: improvementResult, finalTestCase, changesApplied: applyHighConfidenceChanges }, null, 2); } return { content: [ { type: "text" as const, text: formattedResult } ] }; } catch (error: any) { const errorMsg = sanitizeErrorMessage(error, 'Error improving test case', 'improveTestCase'); return { content: [ { type: "text" as const, text: errorMsg } ] }; } }
  • Zod schema defining input parameters for improve_test_case tool: projectKey, caseKey, optional custom rules/checkpoints files, output format, and flag to auto-apply high-confidence improvements.
    export const ImproveTestCaseInputSchema = z.object({ projectKey: z.string().min(1), caseKey: z.string().min(1), rulesFilePath: z.string().optional(), checkpointsFilePath: z.string().optional(), format: z.enum(['dto', 'json', 'string', 'markdown']).default('markdown'), applyHighConfidenceChanges: z.boolean().default(true) }); // Type exports for input schemas export type GetTestCasesInput = z.infer<typeof GetTestCasesInputSchema>; export type GetTestSuitesInput = z.infer<typeof GetTestSuitesInputSchema>; export type GetTestRunsInput = z.infer<typeof GetTestRunsInputSchema>; export type GetTestResultsInput = z.infer<typeof GetTestResultsInputSchema>; export type FindTestCaseByKeyInput = z.infer<typeof FindTestCaseByKeyInputSchema>; export type GetSuiteHierarchyInput = z.infer<typeof GetSuiteHierarchyInputSchema>; export type GetLauncherDetailsInput = z.infer<typeof GetLauncherDetailsInputSchema>; export type AnalyzeTestFailureInput = z.infer<typeof AnalyzeTestFailureInputSchema>; export type ValidateTestCaseInput = z.infer<typeof ValidateTestCaseInputSchema>; export type ImproveTestCaseInput = z.infer<typeof ImproveTestCaseInputSchema>;
  • Core helper method in TestCaseImprover class that processes validation issues, generates improvement suggestions (automatic/content/structure), applies high-confidence fixes, suggests structural enhancements, and returns ImprovementResult with improved test case draft.
    async improveTestCase( originalTestCase: ZebrunnerTestCase, validationResult: ValidationResult ): Promise<ImprovementResult> { const improvements: ImprovementSuggestion[] = []; const humanHelpReasons: string[] = []; let improvedTestCase = JSON.parse(JSON.stringify(originalTestCase)); // Deep clone let canImprove = false; let requiresHumanHelp = false; // Process each validation issue for (const issue of validationResult.issues) { const improvement = await this.processIssue(issue, originalTestCase, improvedTestCase); if (improvement) { improvements.push(improvement); canImprove = true; // Apply the improvement if it's automatic or high confidence if (improvement.type === 'automatic' || improvement.confidence === 'high') { this.applyImprovement(improvement, improvedTestCase); } } else { // Issue requires human help requiresHumanHelp = true; humanHelpReasons.push(`${issue.category}: ${issue.description}`); } } // Additional structural improvements const structuralImprovements = this.suggestStructuralImprovements(originalTestCase); improvements.push(...structuralImprovements); if (structuralImprovements.length > 0) { canImprove = true; // Apply high-confidence structural improvements structuralImprovements .filter(imp => imp.confidence === 'high') .forEach(imp => this.applyImprovement(imp, improvedTestCase)); } // Determine overall confidence const overallConfidence = this.calculateOverallConfidence(improvements); return { canImprove, requiresHumanHelp, confidence: overallConfidence, improvements, improvedTestCase: canImprove ? improvedTestCase : undefined, humanHelpReasons }; }

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/maksimsarychau/mcp-zebrunner'

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