D
dsh-api-testgen
v0.1.0 · 1 天前发布
接口测试生成:解析 OpenAPI 3.x,为每个接口生成覆盖成功/缺参/非法枚举的测试用例,输出 Python(pytest) 或 TypeScript(vitest) 测试骨架
README
dsh-api-testgen · 接口测试生成
解析 OpenAPI 3.x(JSON / YAML),为每个接口生成覆盖 成功 2xx / 缺少必填路径参数 / 非法枚举值 的接口测试用例,输出 Python(pytest + requests)或 TypeScript(vitest + fetch)测试骨架。纯 Node 实现,无网络、无外部服务。
提供的工具
| 工具 | 作用 |
|---|---|
| gen_tests | 解析规范,生成接口测试文件(pytest 或 vitest) |
安装
bash
dsh plugin add dsh-api-testgen
安装后在 profile 的 package.json 的 dsh.profile.bundles 中加入 "dsh-api-testgen"。
用法示例
根据 openapi.yaml 生成 Python 接口测试
→ 调用 gen_tests(spec="openapi.yaml", lang="python")
生成 TypeScript(vitest) 接口测试
→ 调用 gen_tests(spec="openapi.yaml", lang="typescript", outDir="./src/__tests__")
说明
BASE_URL。dsh-api-contract(客户端)、dsh-api-mock(Mock 服务器)配合,构成 API 开发三件套。版本兼容矩阵
| DSH 版本 | 状态 | 说明 |
|---|---|---|
dsh@0.1.0-rc.6 | ✅ 兼容 | cordis patch ✅ |
dsh@0.1.0 | ✅ 兼容 | 标准 patch ✅ |
dsh@0.2.0 | ⚠️ 待验证 | 待实测(API 可能在变) |
dsh@0.3.0+ | ❓ 未知 | 尚未发布 |
💡 兼容矩阵每周末自动跑实测,欢迎 PR 修正
元数据
- License
- MIT
- npm
- dsh-api-testgen
- Repo
- —
- Engines
{}- Weekly DL
- 0
- Monthly DL
- 0
- dsh.bundle
{"bundle":{"patch":"./cordis.patch.yml"}}