bdd-regression-test-generator
bdd-regression-test-generator
REST API エンドポイントと OpenAPI/Swagger サービス契約を解析して、以下を生成する自律エージェントです:
BDD Gherkin 仕様(
.featureファイル)。すべてのハッピーパスとエッジケースのシナリオを記述します。TypeScript 回帰テストスクリプト(Jest + Playwright 対応)。実際のサービスに対してすぐに実行できます。
2つのインターフェースを提供します:
インターフェース | 説明 |
CLI |
|
MCP Server | MCP 対応ホスト(例:IBM Bob、Claude Desktop)に公開可能な Model Context Protocol サーバー |
機能
OpenAPI 3.x および Swagger 2.0 の契約(JSON または YAML)を解析します。
すべてのパス、HTTP メソッド、パラメータ、リクエストボディ、レスポンススキーマを抽出します。
エンドポイントのタググループごとに 1 つの
.featureファイルを生成します。エンドポイントのタググループごとに、完全に型付けされた Jest テストケースを含む
*.spec.tsファイルを 1 つ生成します。生成時にカスタムベース 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 deployed
Maintenance
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.
- TypeshipOAuthdev.typeship
Generate a typed SDK, CLI, and MCP server from any OpenAPI or GraphQL spec, and keep them current.
327 dev tools via REST API and MCP. Generate Dockerfiles, schemas, K8s, APIs, and more.
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 di1010 npm2MIT
- 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.4 npm1MIT
- AlicenseNot gradedqualityCmaintenanceHigh-performance MCP server for OpenAPI specifications that parses specs, diffs versions, tracks dependencies, and generates code (TypeScript, Rust, Python).3 npm2MIT