get_test_result
Retrieve test results for WordPress/WooCommerce plugins using test run IDs. Access security, e2e, and activation test outcomes from the QIT testing framework.
Instructions
Get test result(s) by test run ID.
⚠️ QIT CLI not detected. QIT CLI not found. Please install it using one of these methods:
Via Composer (recommended): composer require woocommerce/qit-cli --dev
Set QIT_CLI_PATH environment variable: export QIT_CLI_PATH=/path/to/qit
Ensure 'qit' is available in your system PATH
For more information, visit: https://github.com/woocommerce/qit-cli
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| test_run_id | Yes | Single test run ID or array of test run IDs | |
| json | No | Return output in JSON format |
Implementation Reference
- src/tools/test-results.ts:17-80 (handler)The handler function that implements the core logic of the 'get_test_result' tool. Validates input test_run_id(s), constructs and executes the appropriate 'qit test-result get' or 'get-multiple' CLI command, processes the output, and returns formatted content or error.handler: async (args: { test_run_id: string | string[]; json?: boolean; }) => { const ids = Array.isArray(args.test_run_id) ? args.test_run_id : [args.test_run_id]; // Validate test run IDs - must be numeric and within reasonable bounds // PHP_INT_MAX on 64-bit is 9223372036854775807 const MAX_VALID_ID = BigInt("9223372036854775807"); for (const id of ids) { if (!/^\d+$/.test(id)) { return { content: `Error: Invalid test run ID "${id}". Test run IDs must be numeric.`, isError: true, }; } try { if (BigInt(id) > MAX_VALID_ID) { return { content: `Error: Test run ID "${id}" is too large. Maximum valid ID is ${MAX_VALID_ID}.`, isError: true, }; } } catch { return { content: `Error: Invalid test run ID "${id}".`, isError: true, }; } } const cmdArgs = ids.length === 1 ? buildArgs("get", [ids[0]], { json: args.json }) : buildArgs("get-multiple", ids, { json: args.json }); const result = await executeQitCommand(cmdArgs); // The get command returns exit code 1 when test status is failed/warning, // but this is not a command error - we still got valid results const output = result.stdout || result.stderr || ""; // Check if we got actual test result data (contains "Test Run Id" or JSON structure) if (output && (output.includes("Test Run Id") || output.includes("test_run_id") || output.startsWith("{"))) { return { content: output, isError: false, }; } // If the output looks like an error (e.g., "Test not found"), report as error if (!result.success) { return { content: `Error: ${output || "Failed to get test result"}`, isError: true, }; } return { content: output || "No result found", isError: false, }; },
- src/tools/test-results.ts:8-16 (schema)Zod schema defining the input parameters for the tool: test_run_id (single string or array of strings) and optional json boolean flag.inputSchema: z.object({ test_run_id: z .union([z.string(), z.array(z.string())]) .describe("Single test run ID or array of test run IDs"), json: z .boolean() .optional() .describe("Return output in JSON format"), }),
- src/server.ts:25-38 (registration)MCP server request handler for listing tools. Converts allTools (including get_test_result) into the MCP tool list format with name, description, and JSON schema.server.setRequestHandler(ListToolsRequestSchema, async () => { // Check if QIT CLI is available const cliInfo = detectQitCli(); const tools = Object.entries(allTools).map(([_, tool]) => ({ name: tool.name, description: cliInfo ? tool.description : `${tool.description}\n\n⚠️ QIT CLI not detected. ${getQitCliNotFoundError()}`, inputSchema: zodToJsonSchema(tool.inputSchema), })); return { tools }; });
- src/server.ts:41-87 (registration)MCP server request handler for calling tools. Looks up the tool by name in allTools, validates arguments using the tool's inputSchema, invokes the handler, and formats the response.server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; const tool = allTools[name as ToolName]; if (!tool) { return { content: [ { type: "text", text: `Unknown tool: ${name}`, }, ], isError: true, }; } try { // Validate input const validatedArgs = tool.inputSchema.parse(args); // Execute tool // eslint-disable-next-line @typescript-eslint/no-explicit-any const result = await (tool.handler as (args: any) => Promise<{ content: string; isError: boolean }>)(validatedArgs); return { content: [ { type: "text", text: result.content, }, ], isError: result.isError, }; } catch (error) { const message = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Error: ${message}`, }, ], isError: true, }; } });