ApiTestGen
API 测试数据自动生成工具 - 从 JSON Schema / OpenAPI 生成正向和负向测试用例。
功能特性
- 从 JSON Schema 自动生成正向测试数据
- 从 OpenAPI 规范自动生成测试数据
- 生成多场景测试用例(展开布尔值、枚举、逻辑分支)
- 自动生成负向测试用例(类型错误、约束违反、边界值等)
- 数据校验功能
- 支持标签过滤(F1-F7 负向用例分类)
安装
pip install apitestgen
快速开始
Python API
from apitestgen import generate, generate_negative, generates, validate
schema = {
"type": "object",
"properties": {
"name": {"type": "string", "minLength": 2},
"email": {"type": "string", "format": "email"},
"age": {"type": "integer", "minimum": 0, "maximum": 150},
},
"required": ["name", "email"],
}
# 生成正向数据
data = generate(schema)
# 生成负向用例
neg_cases = generate_negative(schema)
# 多场景生成
scenarios = generates(schema, options={"expand_bool": True, "expand_enum": True})
# 校验数据
result = validate(data, source=schema)
命令行
# 生成正向测试数据
apitestgen generate schema.json
# 生成负向用例
apitestgen negative schema.json
# 多场景生成
apitestgen generates schema.json --expand-bool --expand-enum
# 校验数据
apitestgen validate schema.json data.json
# 生成完整测试集
apitestgen full schema.json
依赖
- Python >= 3.9
- jsonschema >= 4.0
- faker >= 20.0
- rstr >= 3.0
许可证
MIT License
Metadata
Release files for apitestgen 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| apitestgen-2.0.0.tar.gz | 37.8 kB | Without provenance | Details for apitestgen-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| apitestgen-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for apitestgen-2.0.0-py3-none-any.whl |
Total release size: 88.0 kB
Release files / apitestgen-2.0.0.tar.gz
| Download URL | apitestgen-2.0.0.tar.gz |
|---|---|
| Size | 37.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c5df483ad7a698340ac87af99a7642b0451ac661a8ea03851afa0e3fbd53b9df
|
|
BLAKE2b-256 checksum How to use checksums |
982359c840c11df36a1ea8572b71404b4532040cf75bd480d36a3f96b895149b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|
Release files / apitestgen-2.0.0-py3-none-any.whl
| Download URL | apitestgen-2.0.0-py3-none-any.whl |
|---|---|
| Size | 50.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b60a18ac23177766687288d09b988f85e80cd8b01ac4629da6808df59ac7b488
|
|
BLAKE2b-256 checksum How to use checksums |
867fab79273b4e522f0eba8d0c33f48b67b09872dce42956088736b4a6ff2730
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|
Security for apitestgen 2.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.