auto_generate_tests
Analyze a URL to detect modules and generate pytest tests for each module from candidate test cases. Provides quick coverage for any web application.
Instructions
一鍵交付:在內部依序做 analyze_url → 為每個偵測到的 module 用 candidate_tcs 內容各跑一次 generate_test,把整套 pytest 測試骨架寫進 PROJECT_ROOT/tests/。等同於『analyze_url 後對每個 module 手動跑 N 次 generate_test』的自動化版本,適合「給我一個 URL、其他你看著辦」這種快速覆蓋場景。每條 candidate_tc 變成對應 test 函式的 docstring,run_tests 跑完 HTML 報告會用 docstring 當 case 名稱顯示。回傳產生的檔案路徑列表 + 每個 module 對應幾個 test。預設每個 module 1 條,想要更密的覆蓋拉 tests_per_module。
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | 要分析並批次產測的 URL,需含 protocol(http:// 或 https://)。 | |
| timeout_ms | No | 選填,analyze_url 內部 page.goto 等 DOMContentLoaded 的逾時毫秒。預設 15000,慢站可拉到 30000+。 | |
| auth_cookie | No | 選填,登入後分析所需 cookie,格式:`name1=value1; name2=value2`。從 DevTools / Application / Cookies 抓現成值貼進來。 | |
| tests_per_module | No | 選填,每個 module 從 candidate_tcs 取前 N 條各產一條 test。1-10,預設 1(最少噪音)。想要更密的覆蓋拉 3-5;拉到 10 通常會產 garbage tests,因為 candidate_tcs 後段是泛例。 |