add_results_for_cases
Add test results to a test run using case IDs instead of test IDs. Each result requires a status and can include comments and defects.
Instructions
Add one or more test results to a test run using case IDs instead of test IDs
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 case_id and status_id |
Implementation Reference
- src/tools/add_results_for_cases.ts:16-28 (handler)The handler/definition of the 'add_results_for_cases' tool. It defines the tool name, description, Zod parameters schema, and the async handler that calls client.addResultsForCases() and returns the parsed results.
export const addResultsForCasesTool: ToolDefinition<typeof parameters, TestRailClient> = { name: "add_results_for_cases", description: "Add one or more test results to a test run using case IDs instead of test IDs", parameters, handler: async ({ run_id, results }, client: TestRailClient) => { const response = await client.addResultsForCases(run_id, results); return { success: true, added_count: response.length, results: response.map(r => ResultSchema.parse(r)), }; }, }; - The Zod schema for the tool's input parameters: run_id (number) and results (array of objects with case_id, status_id, optional comment, optional defects).
const parameters = { run_id: z.number().describe("The ID of the test run"), results: z.array(z.object({ case_id: z.number().describe("The ID of the test case. Use get_cases with a project_id to retrieve available case 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 case_id and status_id"), } - src/types/testrail.ts:137-143 (schema)The ResultSchema Zod schema used to parse/validate each result returned from the API.
export const ResultSchema = z.object({ id: z.number(), test_id: z.number(), status_id: z.number(), comment: z.string().nullable(), defects: z.string().nullable(), }); - src/index.ts:22-22 (registration)Import of the addResultsForCasesTool in the main index.ts entry point.
import { addResultsForCasesTool } from "./tools/add_results_for_cases.js"; - src/index.ts:73-73 (registration)Registration of addResultsForCasesTool in the tools array that gets registered via server.registerTool() on line 88.
addResultsForCasesTool, - src/client/testrail.ts:187-189 (helper)The TestRailClient.addResultsForCases() method that makes the actual POST API call to TestRail's add_results_for_cases endpoint.
async addResultsForCases(runId: number, results: Array<Record<string, any>>): Promise<Result[]> { return this.post<Result[]>(`${API_BASE_V2}/add_results_for_cases/${runId}`, { results }); }