Skip to main content
Glama
felipeassis10

bdd-regression-test-generator

bdd-regression-test-generator

一个自主代理,用于分析 REST API 端点和 OpenAPI/Swagger 服务契约,以生成:

  • BDD Gherkin 规范.feature 文件),描述所有正常路径和边界场景。

  • TypeScript 回归测试脚本(Jest + Playwright 就绪),可直接针对真实服务运行。

它提供两种接口:

接口

描述

CLI

bdd-gen generate --input <spec> --output <dir>

MCP 服务器

Model Context Protocol 服务器,可暴露给任何支持 MCP 的主机(例如 IBM Bob、Claude Desktop)


功能特性

  • 解析 OpenAPI 3.x 和 Swagger 2.0 契约(JSON 或 YAML)。

  • 提取所有路径、HTTP 方法、参数、请求体和响应模式。

  • 为每个端点标签组生成一个 .feature 文件。

  • 为每个端点标签组生成一个 *.spec.ts 文件,包含完全类型化的 Jest 测试用例。

  • 支持在生成时注入自定义基础 URL。

  • MCP 服务器暴露 analyze_contractgenerate_gherkingenerate_tests 工具。


Related MCP server: Swagger Testcase MCP

安装

npm install
npm run build

构建后作为全局 CLI 使用:

npm link

CLI 用法

# Generate both Gherkin and Jest tests from an OpenAPI YAML spec
bdd-gen generate --input ./petstore.yaml --output ./generated --baseUrl https://api.example.com

# Generate only Gherkin feature files
bdd-gen generate --input ./petstore.json --output ./generated --only gherkin

# Generate only Jest test scripts
bdd-gen generate --input ./petstore.json --output ./generated --only jest

# Analyze a contract and print a summary (no file generation)
bdd-gen analyze --input ./petstore.yaml

CLI 选项

选项

别名

描述

默认值

--input <path>

-i

OpenAPI/Swagger 契约文件的路径

必填

--output <dir>

-o

生成文件将写入的目录

./generated

--baseUrl <url>

-b

嵌入到生成的测试文件中的基础 URL

http://localhost:3000

--only <type>

仅生成 gherkinjest(省略则两者都生成)

两者

--verbose

-v

启用详细日志输出

false


MCP 服务器

使用以下命令启动 MCP 服务器:

npm run mcp

服务器注册以下工具:

analyze_contract

从文件路径或原始 JSON/YAML 字符串解析 OpenAPI/Swagger 契约。

输入:

{ "source": "./petstore.yaml" }

输出: 一个结构化的 ContractSummary JSON 对象,包含路径、方法、参数和模式。


generate_gherkin

从已解析的契约生成 Gherkin .feature 内容。

输入:

{
  "source": "./petstore.yaml",
  "outputDir": "./generated"
}

输出: 已写入的 .feature 文件路径列表。


generate_tests

从已解析的契约生成 TypeScript Jest 测试脚本。

输入:

{
  "source": "./petstore.yaml",
  "outputDir": "./generated",
  "baseUrl": "https://api.example.com"
}

输出: 已写入的 .spec.ts 文件路径列表。


项目结构

bdd-regression-test-generator/
├── src/
│   ├── parser/
│   │   └── contract-analyzer.ts   # OpenAPI/Swagger parser and extractor
│   ├── generator/
│   │   ├── gherkin-builder.ts     # Gherkin .feature file builder
│   │   └── jest-builder.ts        # TypeScript Jest spec builder
│   ├── mcp/
│   │   └── server.ts              # MCP server exposing generation tools
│   └── cli.ts                     # Commander-based CLI entry point
├── tests/
│   └── generator.test.ts          # Unit tests for parser and generators
├── dist/                          # Compiled output (after build)
├── package.json
├── tsconfig.json
└── README.md

运行测试

npm test

带覆盖率运行:

npm run test:coverage

示例:生成的 Gherkin

Feature: Pets

  Background:
    Given the API base URL is "https://api.example.com"

  Scenario: GET /pets - list all pets - success
    Given I have valid authentication credentials
    When I send a GET request to "/pets"
    Then the response status code should be 200
    And the response body should match the "PetList" schema

  Scenario: GET /pets - list all pets - unauthorized
    Given I have invalid or missing authentication credentials
    When I send a GET request to "/pets"
    Then the response status code should be 401

示例:生成的 Jest 测试

import axios from 'axios';

const BASE_URL = 'https://api.example.com';

describe('Pets', () => {
  describe('GET /pets', () => {
    it('should return 200 for a valid request', async () => {
      const response = await axios.get(`${BASE_URL}/pets`);
      expect(response.status).toBe(200);
    });
  });
});

许可证

MIT

F
license - not found
Not graded
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    An MCP server for the comprehensive analysis of Swagger 2.0 and OpenAPI 3.x contracts. It allows users to extract detailed information about endpoints, request/response schemas, parameters, and security configurations from API documentation.
  • A
    license
    A
    quality
    F
    maintenance
    MCP server for API test case generation from Swagger/OpenAPI specs. Parses Swagger 2.0 and OpenAPI 3.x, generates test cases across 8 categories (positive, negative, boundary, auth, security, idempotency, pagination, business logic), and exports to Postman, TestRail, Allure, k6, pytest, Gherkin, and CSV. Supports internal corporate APIs with auth headers. Auto-saves export files to your working di
    10
    11
    2
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    High-performance MCP server for OpenAPI specifications that parses specs, diffs versions, tracks dependencies, and generates code (TypeScript, Rust, Python).
    22
    2
    MIT

View all related MCP servers

Related MCP Connectors

  • MCP server for AI access to Swagger by SmartBear.

  • MCP server for AI access to SmartBear tools, including BugSnag, Reflect, Swagger, PactFlow, QTM4J.

  • Generate a typed SDK, CLI, and MCP server from any OpenAPI or GraphQL spec, and keep them current.

View all MCP Connectors

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/felipeassis10/bdd-regression-test-generator'

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