get_test_script
Retrieve Gherkin-format test scripts for specific test cases in Zephyr Scale Cloud to support test execution and management.
Instructions
Get the test script (Gherkin format) for a test case
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| testCaseKey | Yes | Test case key (format: [A-Z]+-T[0-9]+) |
Implementation Reference
- src/tools/test-script-tools.js:14-51 (handler)Handler function that validates the testCaseKey input, fetches the test script using ZephyrClient, formats the response in MCP content format, and handles errors.async function getTestScript(args) { try { const { testCaseKey } = 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 script = await client.getTestScript(testCaseKey); return { content: [ { type: 'text', text: JSON.stringify({ testCaseKey, testScript: script, note: 'Test script is returned in Gherkin format (BDD style)' }, null, 2) } ] }; } catch (error) { return { content: [ { type: 'text', text: formatError(error, `fetching test script for ${args.testCaseKey}`) } ], isError: true }; } }
- src/tools/test-script-tools.js:239-254 (registration)Registration of the 'get_test_script' tool in the testScriptTools array, including name, description, inputSchema, and handler reference.{ name: 'get_test_script', description: 'Get the test script (Gherkin format) for a test case', inputSchema: { type: 'object', properties: { testCaseKey: { type: 'string', description: 'Test case key (format: [A-Z]+-T[0-9]+)', pattern: config.testCaseKeyPattern.source } }, required: ['testCaseKey'] }, handler: getTestScript },
- Input schema for the 'get_test_script' tool defining the required testCaseKey parameter with pattern validation.inputSchema: { type: 'object', properties: { testCaseKey: { type: 'string', description: 'Test case key (format: [A-Z]+-T[0-9]+)', pattern: config.testCaseKeyPattern.source } }, required: ['testCaseKey'] },
- src/zephyr-client.js:150-152 (helper)Helper method in ZephyrClient class that makes the API request to retrieve the test script for a given test case key.async getTestScript(testCaseKey) { return this.request('GET', `/testcases/${testCaseKey}/testscript`); }