Ai Test Strategy Architect
/install ai-test-strategy-architect
\r \r
AI Test Strategy Architect\r
\r
Overview\r
\r Build testing that catches bugs before users do. This AI-powered testing assistant designs robust test strategies, generates comprehensive test cases, and implements automation frameworks—turning quality assurance from a bottleneck into a competitive advantage.\r \r
Triggers\r
\r
- 中文触发词:
测试策略、单元测试、集成测试、E2E测试、自动化测试、测试用例、TDD、BDD、Playwright测试、Selenium、测试覆盖率\r - English triggers:
test strategy,unit testing,integration testing,e2e testing,automated testing,test cases,TDD,BDD,Playwright,Selenium,test coverage,CI/CD testing\r \r
Features\r
\r
1. Test Strategy Design\r
- Assess project requirements and risk profiles\r
- Design tailored testing pyramids (unit/integration/e2e ratios)\r
- Select appropriate testing frameworks per use case\r
- Define test data management strategies\r
- Create test environment specifications\r \r
2. Test Case Generation\r
- Generate unit tests from code functions/methods\r
- Create integration test scenarios from API specs\r
- Design end-to-end user journey tests\r
- Build property-based tests for edge cases\r
- Generate negative test cases (error handling)\r \r
3. Test Automation Implementation\r
- Scaffold test projects with proper structure\r
- Implement page object models for UI tests\r
- Set up API test frameworks with data-driven approaches\r
- Configure test parallelization and distribution\r
- Implement visual regression testing\r \r
4. CI/CD Pipeline Integration\r
- Design testing stages in CI/CD pipelines\r
- Configure test reporting and dashboards\r
- Set up automated quality gates\r
- Implement canary/feature flag testing strategies\r
- Create performance test thresholds in pipelines\r \r
Workflow\r
\r
Comprehensive Test Strategy Workflow\r
\r
Phase 1: Assessment\r
├── Analyze project architecture\r
├── Identify critical user flows\r
├── Assess technical risks\r
├── Define quality metrics\r
└── Select testing tools\r
\r
Phase 2: Design\r
├── Design test pyramid\r
├── Define test scope per layer\r
├── Create test data strategy\r
├── Document test environment needs\r
└── Plan test automation approach\r
\r
Phase 3: Implementation\r
├── Set up test project structure\r
├── Implement unit tests\r
├── Build integration test suite\r
├── Create e2e test scenarios\r
└── Configure test runners\r
\r
Phase 4: Automation\r
├── Integrate with CI/CD\r
├── Set up test reporting\r
├── Configure parallel execution\r
├── Implement test monitoring\r
└── Create quality dashboards\r
\r
Phase 5: Maintenance\r
├── Review test effectiveness\r
├── Optimize slow tests\r
├── Update for new features\r
└── Archive obsolete tests\r
```\r
\r
### Quick Test Generation Workflow\r
\r
```\r
1. INPUT: Source code or feature description\r
↓\r
2. ANALYZE: Identify testable units\r
- Functions/methods\r
- User interactions\r
- API endpoints\r
↓\r
3. GENERATE: Create test cases\r
- Happy path scenarios\r
- Edge cases\r
- Error scenarios\r
- Boundary conditions\r
↓\r
4. VALIDATE: Run tests, fix failures\r
↓\r
5. OPTIMIZE: Improve coverage and speed\r
```\r
\r
## Input Examples\r
\r
### Example 1: Function to Unit Test\r
\r
**Input Code:**\r
```python\r
def calculate_discount(price: float, discount_percent: float, is_loyal: bool) -> float:\r
"""\r
Calculate final price after discount.\r
\r
Args:\r
price: Original price\r
discount_percent: Discount percentage (0-100)\r
is_loyal: Whether customer is a loyalty member\r
\r
Returns:\r
Final price after discount\r
"""\r
if price \x3C 0:\r
raise ValueError("Price cannot be negative")\r
if discount_percent \x3C 0 or discount_percent > 100:\r
raise ValueError("Discount must be between 0 and 100")\r
\r
discount_multiplier = 1 - (discount_percent / 100)\r
\r
if is_loyal:\r
# Loyalty members get extra 5% off\r
final_multiplier = discount_multiplier * 0.95\r
else:\r
final_multiplier = discount_multiplier\r
\r
return round(price * final_multiplier, 2)\r
```\r
\r
**Generated Test Cases:**\r
```python\r
import pytest\r
from your_module import calculate_discount\r
\r
class TestCalculateDiscount:\r
"""Unit tests for calculate_discount function"""\r
\r
# Happy path tests\r
def test_no_discount_returns_original_price(self):\r
"""No discount should return the original price"""\r
assert calculate_discount(100.00, 0, False) == 100.00\r
\r
def test_standard_discount(self):\r
"""Basic discount calculation"""\r
assert calculate_discount(100.00, 20, False) == 80.00\r
\r
def test_loyal_customer_extra_discount(self):\r
"""Loyal customers get additional 5% off"""\r
result = calculate_discount(100.00, 20, True)\r
expected = round(100 * 0.80 * 0.95, 2) # 76.00\r
assert result == expected\r
\r
def test_full_discount(self):\r
"""100% discount should result in 0"""\r
assert calculate_discount(100.00, 100, False) == 0.00\r
\r
# Edge cases\r
def test_zero_price(self):\r
"""Zero price should return zero"""\r
assert calculate_discount(0.00, 50, False) == 0.00\r
\r
def test_rounding_to_cents(self):\r
"""Prices should round to 2 decimal places"""\r
result = calculate_discount(99.99, 33, False)\r
assert result == round(99.99 * 0.67, 2)\r
\r
# Error cases\r
def test_negative_price_raises_error(self):\r
"""Negative price should raise ValueError"""\r
with pytest.raises(ValueError, match="Price cannot be negative"):\r
calculate_discount(-10.00, 10, False)\r
\r
def test_negative_discount_raises_error(self):\r
"""Negative discount should raise ValueError"""\r
with pytest.raises(ValueError, match="Discount must be between"):\r
calculate_discount(100.00, -5, False)\r
\r
def test_over_100_discount_raises_error(self):\r
"""Discount over 100% should raise ValueError"""\r
with pytest.raises(ValueError, match="Discount must be between"):\r
calculate_discount(100.00, 150, False)\r
\r
# Boundary tests\r
def test_boundary_zero_percent_discount(self):\r
"""0% is valid discount"""\r
assert calculate_discount(50.00, 0, False) == 50.00\r
\r
def test_boundary_hundred_percent_discount(self):\r
"""100% is valid discount"""\r
assert calculate_discount(50.00, 100, False) == 0.00\r
```\r
\r
### Example 2: API Integration Test\r
\r
**Input:** OpenAPI endpoint definition\r
```yaml\r
paths:\r
/api/v1/users/{userId}/orders:\r
get:\r
summary: Get user orders\r
parameters:\r
- name: userId\r
in: path\r
required: true\r
schema:\r
type: string\r
- name: status\r
in: query\r
schema:\r
type: string\r
enum: [pending, shipped, delivered]\r
responses:\r
'200':\r
description: List of orders\r
'401':\r
description: Unauthorized\r
'404':\r
description: User not found\r
```\r
\r
**Generated Integration Test:**\r
```python\r
import pytest\r
import requests\r
from typing import Dict\r
\r
BASE_URL = "https://api.example.com"\r
HEADERS = {"Authorization": "Bearer \x3Ctest_token>"}\r
\r
class TestUserOrdersAPI:\r
"""Integration tests for User Orders endpoint"""\r
\r
@pytest.fixture\r
def test_user_id(self):\r
"""Fixture providing a test user with known orders"""\r
return "user_123"\r
\r
def test_get_orders_success(self, test_user_id: str):\r
"""Should return 200 with list of orders"""\r
response = requests.get(\r
f"{BASE_URL}/api/v1/users/{test_user_id}/orders",\r
headers=HEADERS\r
)\r
\r
assert response.status_code == 200\r
data = response.json()\r
assert "orders" in data\r
assert isinstance(data["orders"], list)\r
\r
def test_get_orders_with_status_filter(self, test_user_id: str):\r
"""Should filter orders by status"""\r
response = requests.get(\r
f"{BASE_URL}/api/v1/users/{test_user_id}/orders",\r
params={"status": "pending"},\r
headers=HEADERS\r
)\r
\r
assert response.status_code == 200\r
orders = response.json()["orders"]\r
assert all(order["status"] == "pending" for order in orders)\r
\r
def test_get_orders_unauthorized(self, test_user_id: str):\r
"""Should return 401 without valid token"""\r
response = requests.get(\r
f"{BASE_URL}/api/v1/users/{test_user_id}/orders"\r
)\r
\r
assert response.status_code == 401\r
\r
def test_get_orders_user_not_found(self):\r
"""Should return 404 for non-existent user"""\r
response = requests.get(\r
f"{BASE_URL}/api/v1/users/nonexistent_user/orders",\r
headers=HEADERS\r
)\r
\r
assert response.status_code == 404\r
assert "error" in response.json()\r
```\r
\r
### Example 3: E2E Test with Playwright\r
\r
**Input:** User journey description\r
```\r
User flow: Login -> Add item to cart -> Checkout -> Verify order confirmation\r
```\r
\r
**Generated E2E Test:**\r
```python\r
import pytest\r
from playwright.sync_api import Page, expect\r
\r
@pytest.fixture\r
def logged_in_page(page: Page):\r
"""Fixture that logs in user before each test"""\r
page.goto("https://shop.example.com/login")\r
page.fill('[name="email"]', "[email protected]")\r
page.fill('[name="password"]', "testpassword123")\r
page.click('[type="submit"]')\r
page.wait_for_url("**/dashboard")\r
return page\r
\r
def test_complete_checkout_flow(logged_in_page: Page):\r
"""End-to-end test: Login -> Add to cart -> Checkout -> Confirmation"""\r
page = logged_in_page\r
\r
# Step 1: Browse to product\r
page.goto("https://shop.example.com/products/widget-pro")\r
page.click('[data-testid="add-to-cart"]')\r
\r
# Step 2: Verify cart\r
page.click('[data-testid="cart-icon"]')\r
expect(page.locator('[data-testid="cart-item"]')).toHaveCount(1)\r
\r
# Step 3: Proceed to checkout\r
page.click('[data-testid="checkout-button"]')\r
page.fill('[name="shipping_address"]', "123 Test Street")\r
page.fill('[name="zip_code"]', "12345")\r
page.click('[data-testid="continue-payment"]')\r
\r
# Step 4: Complete payment\r
page.fill('[name="card_number"]', "4242424242424242")\r
page.fill('[name="expiry"]', "12/28")\r
page.fill('[name="cvv"]', "123")\r
page.click('[data-testid="place-order"]')\r
\r
# Step 5: Verify confirmation\r
expect(page.locator('[data-testid="order-confirmation"]')).toBeVisible()\r
expect(page.locator('[data-testid="order-number"]')).not_toBeEmpty()\r
```\r
\r
## Output Templates\r
\r
### Template: Test Strategy Document\r
```markdown\r
# Test Strategy Document\r
\r
## Project Overview\r
- Project Name: [Name]\r
- Version: [Version]\r
- Test Scope: [What's in/out]\r
\r
## Quality Objectives\r
| Metric | Target | Measurement |\r
|--------|--------|-------------|\r
| Code Coverage | >80% | Codecov |\r
| Bug Escape Rate | \x3C5% | Bug Tracker |\r
| Test Execution Time | \x3C10 min | CI Pipeline |\r
\r
## Test Pyramid\r
\r
╱╲\r
╱ ╲\r
╱ E2E╲ [Few - 10%]\r
╱──────╲\r
╱Integration╲ [Some - 30%]\r
╱────────────╲\r
╱ Unit Tests ╲ [Many - 60%]\r
╱────────────────╲\r
\r
## Testing Tools\r
\r
| Layer | Tool | Language |\r
|-------|------|----------|\r
| Unit | Pytest | Python |\r
| Integration | pytest | Python |\r
| E2E | Playwright | TypeScript |\r
| API | REST Assured | Java |\r
\r
## Test Environments\r
- Dev: https://dev.example.com\r
- Staging: https://staging.example.com\r
- Production: https://example.com\r
\r
## Test Data Strategy\r
- [Strategy details]\r
\r
## Release Criteria\r
- [ ] All critical tests pass\r
- [ ] Coverage meets target\r
- [ ] No P0 bugs open\r
```\r
\r
## Best Practices\r
\r
### For Test Design\r
1. **Follow FIRST principles:** Fast, Independent, Repeatable, Self-validating, Timely\r
2. **Name tests descriptively:** `test_user_cannot_login_with_invalid_password`\r
3. **Test one thing per test:** Easier debugging and maintenance\r
4. **Use data-driven tests:** Reduce duplication with parameterized tests\r
5. **Test edge cases:** Empty inputs, null values, maximum limits\r
\r
### For Test Automation\r
1. **Prioritize stability:** Flaky tests are worse than no tests\r
2. **Keep tests fast:** Slow tests don't run often\r
3. **Use page objects:** Encapsulate UI structure changes\r
4. **Isolate tests:** No shared state between tests\r
5. **Clean up after yourself:** Reset what you change\r
\r
### For CI/CD Integration\r
1. **Fail fast:** Run fastest tests first\r
2. **Parallelize:** Split tests across workers\r
3. **Report properly:** Generate actionable reports\r
4. **Set quality gates:** Block releases below thresholds\r
5. **Monitor trends:** Track flakiness over time\r
\r
## Testing Framework Comparison\r
\r
| Framework | Best For | Languages |\r
|-----------|----------|-----------|\r
| Pytest | Python APIs, unit tests | Python |\r
| Jest | JavaScript/TypeScript | JS/TS |\r
| JUnit 5 | Java applications | Java |\r
| Playwright | Web E2E testing | TS, Python |\r
| Cypress | Web E2E testing | JS/TS |\r
| Selenium | Legacy browser testing | Multi |\r
| REST Assured | API testing | Java, Groovy |\r
| SuperTest | Node.js API testing | JavaScript |\r
\r
## Version History\r
\r
- **1.0.0** (2026-05-15): Initial release\r
- Test strategy design framework\r
- Unit test generation\r
- Integration test scaffolding\r
- E2E test patterns (Playwright)\r
- CI/CD integration guidance\r
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install ai-test-strategy-architect - 安装完成后,直接呼叫该 Skill 的名称或使用
/ai-test-strategy-architect触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
Ai Test Strategy Architect 是什么?
AI-powered test strategy and automation assistant — design comprehensive testing frameworks, generate unit/integration/e2e test cases, implement test automat... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 102 次。
如何安装 Ai Test Strategy Architect?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install ai-test-strategy-architect」即可一键安装,无需额外配置。
Ai Test Strategy Architect 是免费的吗?
是的,Ai Test Strategy Architect 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
Ai Test Strategy Architect 支持哪些平台?
Ai Test Strategy Architect 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 Ai Test Strategy Architect?
由 lingfeng-19(@gechengling)开发并维护,当前版本 v1.0.0。