Skip to main content
Glama

create_bdd_test_script

Generate BDD test scripts in Gherkin format for Zephyr Scale Cloud, validating steps and structuring scenarios with Given/When/Then syntax.

Instructions

Create a BDD test script using Gherkin format with helper validation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
testCaseKeyYesTest case key (format: [A-Z]+-T[0-9]+)
featureNoFeature description for the BDD script
scenarioNoScenario description for the BDD script
stepsNoArray of Gherkin steps (must start with Given/When/Then/And/But)

Implementation Reference

  • Main handler function that validates inputs (testCaseKey, feature, scenario, steps), builds a Gherkin-formatted BDD test script, calls createTestScript to persist it to Zephyr, and enhances the response with helper info.
    async function createBddTestScript(args) {
      try {
        const { testCaseKey, feature, scenario, steps } = 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]+');
        }
    
        // Build Gherkin script
        let gherkinScript = '';
    
        if (feature) {
          gherkinScript += `Feature: ${feature}\n\n`;
        }
    
        if (scenario) {
          gherkinScript += `Scenario: ${scenario}\n`;
        }
    
        if (steps && Array.isArray(steps)) {
          if (steps.length === 0) {
            throw new Error('At least one step must be provided');
          }
    
          const validStepKeywords = ['Given', 'When', 'Then', 'And', 'But'];
    
          steps.forEach((step, index) => {
            if (typeof step !== 'string' || step.trim().length === 0) {
              throw new Error(`Step ${index + 1} must be a non-empty string`);
            }
    
            const stepText = step.trim();
            const hasKeyword = validStepKeywords.some(keyword =>
              stepText.toLowerCase().startsWith(keyword.toLowerCase())
            );
    
            if (!hasKeyword) {
              throw new Error(`Step ${index + 1} must start with a Gherkin keyword: Given, When, Then, And, or But`);
            }
    
            gherkinScript += `    ${stepText}\n`;
          });
        } else if (!feature && !scenario) {
          throw new Error('Either steps array or feature/scenario text must be provided');
        }
    
        // Create the script using the base function
        const result = await createTestScript({
          testCaseKey,
          text: gherkinScript,
          type: 'bdd'
        });
    
        // Add additional info to the response
        const originalContent = result.content[0].text;
        let parsedContent;
    
        try {
          parsedContent = JSON.parse(originalContent);
        } catch (parseError) {
          // If JSON parsing fails, return the original result with error info
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify({
                  error: 'Failed to parse createTestScript response',
                  originalResponse: originalContent,
                  parseError: parseError.message,
                  bddHelper: {
                    feature,
                    scenario,
                    stepsCount: steps ? steps.length : 0,
                    generatedScript: gherkinScript
                  }
                }, null, 2)
              }
            ],
            isError: true
          };
        }
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify({
                ...parsedContent,
                bddHelper: {
                  feature,
                  scenario,
                  stepsCount: steps ? steps.length : 0,
                  generatedScript: gherkinScript
                }
              }, null, 2)
            }
          ]
        };
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: formatError(error, `creating BDD test script for ${args.testCaseKey}`)
            }
          ],
          isError: true
        };
      }
    }
  • JSON schema defining the input parameters for the tool: required testCaseKey, optional feature, scenario, and steps array of strings.
    inputSchema: {
      type: 'object',
      properties: {
        testCaseKey: {
          type: 'string',
          description: 'Test case key (format: [A-Z]+-T[0-9]+)',
          pattern: config.testCaseKeyPattern.source
        },
        feature: {
          type: 'string',
          description: 'Feature description for the BDD script'
        },
        scenario: {
          type: 'string',
          description: 'Scenario description for the BDD script'
        },
        steps: {
          type: 'array',
          description: 'Array of Gherkin steps (must start with Given/When/Then/And/But)',
          items: {
            type: 'string',
            description: 'Gherkin step (e.g., "Given I am logged in" or "When I click the button")'
          },
          minItems: 1
        }
      },
      required: ['testCaseKey']
    },
  • Tool object registration within the testScriptTools export array, specifying name, description, inputSchema, and handler reference.
    {
      name: 'create_bdd_test_script',
      description: 'Create a BDD test script using Gherkin format with helper validation',
      inputSchema: {
        type: 'object',
        properties: {
          testCaseKey: {
            type: 'string',
            description: 'Test case key (format: [A-Z]+-T[0-9]+)',
            pattern: config.testCaseKeyPattern.source
          },
          feature: {
            type: 'string',
            description: 'Feature description for the BDD script'
          },
          scenario: {
            type: 'string',
            description: 'Scenario description for the BDD script'
          },
          steps: {
            type: 'array',
            description: 'Array of Gherkin steps (must start with Given/When/Then/And/But)',
            items: {
              type: 'string',
              description: 'Gherkin step (e.g., "Given I am logged in" or "When I click the button")'
            },
            minItems: 1
          }
        },
        required: ['testCaseKey']
      },
      handler: createBddTestScript
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but only states what the tool creates, not how it behaves. It doesn't disclose whether this is a write operation, what permissions might be needed, what happens if validation fails, or what the output looks like. 'Helper validation' is mentioned but not explained.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that states the core purpose without unnecessary elaboration. Every word earns its place, and it's appropriately front-loaded with the main action.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a creation tool with 4 parameters and no annotations or output schema, the description is insufficient. It doesn't explain the creation process, validation behavior, error conditions, or relationship to sibling tools. The mention of 'helper validation' is too vague to be helpful.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all 4 parameters thoroughly. The description adds no additional parameter information beyond what's in the schema, meeting the baseline expectation when schema coverage is complete.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Create a BDD test script') and specifies the format ('using Gherkin format with helper validation'), which distinguishes it from generic test script creation tools. However, it doesn't explicitly differentiate from sibling 'create_test_script' beyond mentioning the BDD/Gherkin aspect.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided about when to use this tool versus alternatives like 'create_test_script' or 'create_test_case'. The description mentions the format but doesn't explain the specific use cases for BDD test scripts versus other test artifacts.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/donyfs/mcp-zephyr'

If you have feedback or need assistance with the MCP directory API, please join our Discord server