add_results
Add test results to a test run. Specify status, comment, and defects for each test. Send multiple results in one request.
Instructions
Add one or more test results to a test run
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| run_id | Yes | The ID of the test run | |
| results | Yes | Array of results to add. Each result must have test_id and status_id |
Implementation Reference
- src/tools/add_results.ts:1-28 (handler)The add_results tool handler implementation. Defines parameters schema (run_id, results array with test_id, status_id, optional comment/defects) and a handler that calls client.addResults() and returns parsed results.
import { TestRailClient } from "../client/testrail.js"; import { z } from "zod"; import { ResultSchema } from "../types/testrail.js"; import { ToolDefinition } from "../types/custom.js"; const parameters = { run_id: z.number().describe("The ID of the test run"), results: z.array(z.object({ test_id: z.number().describe("The ID of the test. Use get_tests with a run_id to retrieve available test IDs"), status_id: z.number().describe("The ID of the test status (e.g. Passed, Failed). Use get_statuses to retrieve available status IDs"), comment: z.string().optional().describe("Optional comment/description for the result"), defects: z.string().optional().describe("Optional comma-separated list of defect IDs"), })).describe("Array of results to add. Each result must have test_id and status_id"), } export const addResultsTool: ToolDefinition<typeof parameters, TestRailClient> = { name: "add_results", description: "Add one or more test results to a test run", parameters, handler: async ({ run_id, results }, client: TestRailClient) => { const response = await client.addResults(run_id, results); return { success: true, added_count: response.length, results: response.map(r => ResultSchema.parse(r)), }; }, }; - src/tools/add_results.ts:6-14 (schema)Input validation schema for add_results tool: requires run_id (number) and results (array of objects with test_id, status_id, optional comment and defects).
const parameters = { run_id: z.number().describe("The ID of the test run"), results: z.array(z.object({ test_id: z.number().describe("The ID of the test. Use get_tests with a run_id to retrieve available test IDs"), status_id: z.number().describe("The ID of the test status (e.g. Passed, Failed). Use get_statuses to retrieve available status IDs"), comment: z.string().optional().describe("Optional comment/description for the result"), defects: z.string().optional().describe("Optional comma-separated list of defect IDs"), })).describe("Array of results to add. Each result must have test_id and status_id"), } - src/index.ts:72-73 (registration)The add_results tool is registered in the tools array at src/index.ts line 72, and the generic registration loop (lines 87-110) calls server.registerTool() to register each tool by name.
addResultsTool, addResultsForCasesTool, - src/client/testrail.ts:183-185 (helper)The TestRailClient.addResults() method that makes the POST API call to TestRail's /add_results/{run_id} endpoint.
async addResults(runId: number, results: Array<Record<string, any>>): Promise<Result[]> { return this.post<Result[]>(`${API_BASE_V2}/add_results/${runId}`, { results }); } - src/types/testrail.ts:137-145 (schema)ResultSchema zod definition used to validate the response from add_results (id, test_id, status_id, comment, defects).
export const ResultSchema = z.object({ id: z.number(), test_id: z.number(), status_id: z.number(), comment: z.string().nullable(), defects: z.string().nullable(), }); export type Result = z.infer<typeof ResultSchema>