bdd-regression-test-generator
bdd-regression-test-generator
一个自主代理,用于分析 REST API 端点和 OpenAPI/Swagger 服务契约,以生成:
BDD Gherkin 规范(
.feature文件),描述所有正常路径和边界场景。TypeScript 回归测试脚本(Jest + Playwright 就绪),可直接针对真实服务运行。
它提供两种接口:
接口 | 描述 |
CLI |
|
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_contract、generate_gherkin和generate_tests工具。
Related MCP server: Swagger Testcase MCP
安装
npm install
npm run build构建后作为全局 CLI 使用:
npm linkCLI 用法
# 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.yamlCLI 选项
选项 | 别名 | 描述 | 默认值 |
|
| OpenAPI/Swagger 契约文件的路径 | 必填 |
|
| 生成文件将写入的目录 |
|
|
| 嵌入到生成的测试文件中的基础 URL |
|
| 仅生成 | 两者 | |
|
| 启用详细日志输出 |
|
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
This server cannot be installed
Maintenance
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
- FlicenseNot gradedqualityDmaintenanceAn 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.
- AlicenseAqualityFmaintenanceMCP 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 di10112MIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server that automates Playwright-based UI and API testing, supporting test case generation from requirements or API specs, and execution with detailed reports.121MIT
- AlicenseNot gradedqualityCmaintenanceHigh-performance MCP server for OpenAPI specifications that parses specs, diffs versions, tracks dependencies, and generates code (TypeScript, Rust, Python).222MIT
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.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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