update_test_case
Modify existing test cases in Zephyr Scale Cloud by updating details like name, description, objectives, and labels to maintain accurate test documentation.
Instructions
Update an existing test case
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| testCaseKey | Yes | Test case key to update (format: [A-Z]+-T[0-9]+) | |
| name | No | Updated name of the test case | |
| description | No | Updated description of the test case | |
| folderId | No | Updated folder ID | |
| component | No | Updated component ID | |
| labels | No | Updated labels (single string or array of strings) | |
| objective | No | Updated test objective | |
| precondition | No | Updated test precondition | |
| estimatedTime | No | Updated estimated time in minutes (will be converted to milliseconds) |
Implementation Reference
- src/tools/test-case-tools.js:179-256 (handler)The core handler function that executes the 'update_test_case' tool. It destructures args, validates testCaseKey, fetches the current test case to preserve unchanged fields, builds the update payload, calls the ZephyrClient.updateTestCase method, and formats the success or error response in MCP format.async function updateTestCase(args) { try { const { testCaseKey, name, description, folderId, component, labels, objective, precondition, estimatedTime } = args; if (!testCaseKey) { throw new Error('testCaseKey is required'); } if (!config.testCaseKeyPattern.test(testCaseKey)) { throw new Error('Invalid testCaseKey format. Must match pattern: [A-Z]+-T[0-9]+'); } const currentTestCase = await client.getTestCase(testCaseKey); const testCaseData = { id: currentTestCase.id, key: testCaseKey, name: name !== undefined ? name : currentTestCase.name, project: { id: currentTestCase.project.id }, status: { id: currentTestCase.status.id }, priority: { id: currentTestCase.priority.id }, folder: { id: folderId !== undefined ? folderId : currentTestCase.folder.id }, objective: objective !== undefined ? objective : currentTestCase.objective, precondition: precondition !== undefined ? precondition : currentTestCase.precondition, estimatedTime: estimatedTime !== undefined ? estimatedTime * 60000 // Convert minutes to milliseconds : currentTestCase.estimatedTime, labels: labels !== undefined ? (Array.isArray(labels) ? labels : [labels]) : currentTestCase.labels || [], description: description !== undefined ? description : currentTestCase.description, component: component !== undefined ? component : currentTestCase.component, owner: currentTestCase.owner, customFields: currentTestCase.customFields || {} }; const result = await client.updateTestCase(testCaseKey, testCaseData); return { content: [ { type: 'text', text: JSON.stringify({ message: 'Test case updated successfully', testCase: result }, null, 2) } ] }; } catch (error) { return { content: [ { type: 'text', text: formatError(error, `updating test case ${args.testCaseKey}`) } ], isError: true }; } }
- src/tools/test-case-tools.js:367-417 (schema)The input schema defining the parameters for the 'update_test_case' tool. testCaseKey is required with pattern validation; other fields like name, description, etc., are optional with type constraints.inputSchema: { type: 'object', properties: { testCaseKey: { type: 'string', description: 'Test case key to update (format: [A-Z]+-T[0-9]+)', pattern: config.testCaseKeyPattern.source }, name: { type: 'string', description: 'Updated name of the test case', minLength: 1, maxLength: 255 }, description: { type: 'string', description: 'Updated description of the test case' }, folderId: { type: 'integer', description: 'Updated folder ID', minimum: 1 }, component: { type: 'integer', description: 'Updated component ID', minimum: 1 }, labels: { oneOf: [ { type: 'string' }, { type: 'array', items: { type: 'string' } } ], description: 'Updated labels (single string or array of strings)' }, objective: { type: 'string', description: 'Updated test objective' }, precondition: { type: 'string', description: 'Updated test precondition' }, estimatedTime: { type: 'integer', description: 'Updated estimated time in minutes (will be converted to milliseconds)', minimum: 0 } }, required: ['testCaseKey'] },
- src/tools/test-case-tools.js:364-419 (registration)The tool registration object within the testCaseTools export array. Specifies the name 'update_test_case', description, inputSchema, and references the handler function.{ name: 'update_test_case', description: 'Update an existing test case', inputSchema: { type: 'object', properties: { testCaseKey: { type: 'string', description: 'Test case key to update (format: [A-Z]+-T[0-9]+)', pattern: config.testCaseKeyPattern.source }, name: { type: 'string', description: 'Updated name of the test case', minLength: 1, maxLength: 255 }, description: { type: 'string', description: 'Updated description of the test case' }, folderId: { type: 'integer', description: 'Updated folder ID', minimum: 1 }, component: { type: 'integer', description: 'Updated component ID', minimum: 1 }, labels: { oneOf: [ { type: 'string' }, { type: 'array', items: { type: 'string' } } ], description: 'Updated labels (single string or array of strings)' }, objective: { type: 'string', description: 'Updated test objective' }, precondition: { type: 'string', description: 'Updated test precondition' }, estimatedTime: { type: 'integer', description: 'Updated estimated time in minutes (will be converted to milliseconds)', minimum: 0 } }, required: ['testCaseKey'] }, handler: updateTestCase }
- src/index.js:30-37 (registration)Top-level registration in the MCP server index.js where testCaseTools (including update_test_case) is spread into the allTools array used for dynamic tool lookup and execution.const allTools = [ ...projectTools, ...folderTools, ...testCaseTools, ...testStepsTools, ...testScriptTools, ...referenceDataTools ];
- src/zephyr-client.js:136-138 (helper)The ZephyrClient helper method called by the tool handler. Performs the actual API PUT request to update the test case via the Zephyr Scale Cloud API.async updateTestCase(testCaseKey, testCaseData) { return this.request('PUT', `/testcases/${testCaseKey}`, testCaseData); }