test-fixture-generator

👤 shenghoo123-png 📦 v1.0.0 ⭐ 4.3 ⬇️ 674 下載
💻 開發程式設計 免費

📖 技能介紹

test-fixture-generator

名稱

推薦訪問7w4.net獲取更多AI技能。

test-fixture-generator

描述

自動生成pytest fixtures的工具,支援常見測試場景(資料庫、API mock、檔案處理等)

觸發詞

fixture, pytest fixture, conftest, 測試夾具

指令

生成pytest fixtures程式碼

使用方式

# 生成資料庫fixture
python -m test_fixture_generator generate --type db --db-type mysql

# 生成API mock fixture
python -m test_fixture_generator generate --type api --framework requests

# 生成檔案處理fixture
python -m test_fixture_generator generate --type file --format json

# 生成conftest.py
python -m test_fixture_generator init

# 互動式生成
python -m test_fixture_generator interactive

引數說明

  • --type: fixture型別 (db|api|file|random)
  • --db-type: 資料庫型別 (mysql|postgres|sqlite)
  • --framework: mock框架 (requests|httpx|boto3)
  • --format: 檔案格式 (json|yaml|csv|toml)
  • --output: 輸出檔案路徑

輸出

生成符合pytest規範的fixture程式碼,自動處理setup/teardown

🤖 AI 評測

這個工具質量不錯,能自動生成各種測試用的程式碼模板,省去手動編寫的麻煩。功能豐富,支援多種資料庫和API mock,文件清晰易讀,程式碼結構整齊。不足之處是配置選項較多,新手可能需要花點時間熟悉;部分模板的設定是固定的,不太靈活。總體來說是個好用的輔助工具,適合經常寫測試程式碼的開發者。

📊 多維度評分

適應性4.4
規範性4.1
有效性4.6
可靠性4
可信度4.8

📁 包含檔案 (7 個)

📄 README.md 4.8 KB
📄 SKILL.md 1 KB
📄 __init__.py 279 B
📄 _meta.json 141 B
📄 cli.py 8.8 KB
📄 generator.py 16.7 KB
📄 tests/test_generator.py 10.3 KB