用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/ForceInjection/domain-driven-design-skills --skill test-automation命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Conduct deep academic research for philosophy, neuroscience, cognitive science, and theoretical computer science (computability, complexity, AI theory, logic). Use when user asks to: research academic topics, find scholarly papers, conduct literature reviews, analyze citations, synthesize research findings, explore philosophical arguments, investigate consciousness/cognition, study computability/decidability/Turing machines, or analyze academic debates. Triggers on: 'research papers', 'literature review', 'academic sources', 'scholarly articles', 'philosophy of mind', 'computability theory', 'neuroscience studies', 'find papers on', 'what does the research say'.
Create clear action plans with steps, success criteria, and risk awareness. Use before implementing features, making changes, starting projects, or anytime you need a roadmap to success. Triggers on "plan this", "how should we approach", "what's the strategy", "steps to complete", or when facing complex multi-step work.
Add keyboard navigation to a feature using CommandRegistryService. Use when implementing keyboard shortcuts, vim-style navigation, or hotkeys for a page or component.
基于 SOC 职业分类
正在显示 SKILL.md
| title | test-automation: Create test plans, write tests, validate code quality |
| name | test-automation |
| description | Create test plans, write tests, validate code quality through testing |
| tags | ["sdd-workflow","shared-architecture","quality-assurance"] |
| custom_fields | {"layer":null,"artifact_type":null,"architecture_approaches":["ai-agent-based","traditional-8layer"],"priority":"shared","development_status":"active","skill_category":"quality-assurance","upstream_artifacts":["BDD","SPEC","TASKS"],"downstream_artifacts":[]} |
Description: Automated test generation, BDD execution, coverage analysis, and contract testing
Category: Quality Assurance & Testing
Complexity: High (multi-framework integration + coverage analysis)
Transform SDD artifacts (BDD scenarios, requirements, contracts) into executable test suites with comprehensive coverage tracking. Ensures code implementation matches specifications and contracts.
graph TD
A[SDD Artifacts] --> B{Artifact Type}
B -->|BDD| C[Generate BDD Tests]
B -->|REQ| D[Generate Unit Tests]
B -->|CTR| E[Generate Contract Tests]
B -->|SPEC| F[Generate Integration Tests]
C --> G[pytest-bdd Test Suite]
D --> H[pytest Unit Test Suite]
E --> I[Contract Test Suite]
F --> J[Integration Test Suite]
G --> K[Execute Tests]
H --> K
I --> K
J --> K
K --> L[Coverage Analysis]
L --> M{Coverage Goals Met?}
M -->|No| N[Identify Gaps]
M -->|Yes| O[Generate Report]
N --> P[Generate Additional Tests]
P --> K
O --> Q[Update Traceability Matrix]
# Input: BDD/authentication_scenarios.md
# Output: tests/bdd/test_authentication.py
test-automation generate-bdd \
--input BDD/authentication_scenarios.md \
--output tests/bdd/test_authentication.py \
--framework pytest-bdd
Generated test structure:
import pytest
from pytest_bdd import scenarios, given, when, then, parsers
scenarios('{project_root}/BDD/authentication_scenarios.md')
@given('a user with valid credentials')
def user_with_valid_credentials(context):
context.user = create_test_user(
username='testuser',
password='ValidP@ssw0rd'
)
@when('the user attempts to login')
def user_attempts_login(context):
context.response = login_api(
username=context.user.username,
password=context.user.password
)
@then('the login should succeed')
def login_succeeds(context):
assert context.response.status_code == 200
assert 'access_token' in context.response.json()
# Input: reqs/requirements.md (REQ-AUTH-01)
# Output: tests/unit/test_auth_requirements.py
test-automation generate-unit \
--input reqs/requirements.md \
--filter REQ-AUTH-* \
--output tests/unit/test_auth_requirements.py
Generated test structure:
import pytest
from auth.service import AuthService
class TestREQ_AUTH_001:
"""Test REQ-AUTH-01: Password must be 8-20 characters"""
def test_password_minimum_length(self):
"""Verify password < 8 characters is rejected"""
result = AuthService.validate_password('Short1!')
assert not result.valid
assert 'minimum 8 characters' in result.error
def test_password_maximum_length(self):
"""Verify password > 20 characters is rejected"""
result = AuthService.validate_password('VeryLongPassword123456789!')
assert not result.valid
assert 'maximum 20 characters' in result.error
def test_password_valid_length(self):
"""Verify password 8-20 characters is accepted"""
result = AuthService.validate_password('ValidP@ss1')
assert result.valid
# Input: ctrs/CTR-USER-V1.yaml
# Output: tests/contract/test_user_contract.py
test-automation generate-contract \
--input ctrs/CTR-USER-V1.yaml \
--output tests/contract/test_user_contract.py \
--provider user-service
Generated test structure:
import pytest
from pact import Consumer, Provider, Like, EachLike
@pytest.fixture
def pact():
return Consumer('user-client').has_pact_with(
Provider('user-service')
)
def test_create_user_contract(pact):
expected = {
'user_id': Like('123e4567-e89b-12d3-a456-426614174000'),
'username': Like('testuser'),
'email': Like('test@example.com'),
'created_at': Like('2025-01-01T00:00:00Z')
}
(pact
.given('user database is empty')
.upon_receiving('a request to create a user')
.with_request('POST', '/api/users')
.will_respond_with(201, body=expected))
with pact:
result = user_api.create_user({
'username': 'testuser',
'email': 'test@example.com',
'password': 'SecureP@ss123'
})
assert result.status_code == 201
# Run all tests with coverage
test-automation run \
--coverage \
--coverage-report html \
--traceability
# Run specific test category
test-automation run --category bdd
test-automation run --category unit
test-automation run --category contract
# Run tests for specific requirement
test-automation run --requirement REQ-AUTH-01
test-automation coverage-report \
--format html \
--output reports/coverage \
--include-traceability
Generated report includes:
"""
BDD Tests for {feature_name}
Generated from: {bdd_document_path}
Traceability: {requirement_ids}
"""
import pytest
from pytest_bdd import scenarios, given, when, then, parsers
# Load all scenarios from BDD document
scenarios('{bdd_document_path}')
# Fixtures
@pytest.fixture
def context():
"""Test context for sharing state between steps"""
return {}
# Given steps
@given(parsers.parse('{step_description}'))
def step_given(context, {parameters}):
# Setup preconditions
pass
# When steps
@when(parsers.parse('{step_description}'))
def step_when(context, {parameters}):
# Execute action
pass
# Then steps
@then(parsers.parse('{step_description}'))
def step_then(context, {parameters}):
# Verify outcome
pass
"""
Unit Tests for {requirement_id}
Requirement: {requirement_description}
Source: {requirement_document}
"""
import pytest
from {module} import {class_or_function}
class Test_{requirement_id}:
"""Test suite for {requirement_id}"""
@pytest.fixture
def setup(self):
"""Setup test fixtures"""
return {class_or_function}()
def test_positive_case(self, setup):
"""Test expected behavior"""
result = setup.method({valid_input})
assert result == {expected_output}
def test_boundary_case_min(self, setup):
"""Test minimum boundary value"""
result = setup.method({min_value})
assert {assertion}
def test_boundary_case_max(self, setup):
"""Test maximum boundary value"""
result = setup.method({max_value})
assert {assertion}
def test_invalid_input(self, setup):
"""Test error handling"""
with pytest.raises({expected_exception}):
setup.method({invalid_input})
"""
Integration Tests for {component_name}
Specification: {spec_document}
Contracts: {contract_ids}
"""
import pytest
from {test_client} import TestClient
from {app} import app
@pytest.fixture
def client():
"""Test client for API integration tests"""
return TestClient(app)
class Test_{component_name}_Integration:
"""Integration test suite for {component_name}"""
def test_api_endpoint_{operation}(self, client):
"""Test {operation} operation"""
# Arrange
test_data = {test_payload}
# Act
response = client.{http_method}(
'{endpoint_path}',
json=test_data
)
# Assert
assert response.status_code == {expected_status}
assert response.json() == {expected_response}
"""
Contract Tests for {service_name}
Contract: {contract_id}
Provider: {provider_service}
Consumer: {consumer_service}
"""
import pytest
from pact import Consumer, Provider, Like, EachLike, Term
@pytest.fixture
def pact():
return Consumer('{consumer_service}').has_pact_with(
Provider('{provider_service}'),
host_name='localhost',
port=1234
)
class Test_{contract_id}:
"""Contract test suite for {contract_id}"""
def test_{operation}_contract(self, pact):
"""Test {operation} contract"""
# Define expected interaction
expected = {expected_schema}
# Setup pact
(pact
.given('{provider_state}')
.upon_receiving('{interaction_description}')
.with_request('{method}', '{path}')
.will_respond_with({status}, body=expected))
# Execute and verify
with pact:
result = {client_call}
assert result == expected
# Map requirements to tests
REQ-AUTH-01 → [
test_password_minimum_length,
test_password_maximum_length,
test_password_valid_length
] (100% covered)
REQ-AUTH-002 → [
test_password_uppercase_required,
test_password_lowercase_required
] (50% covered - missing number requirement test)
# Map BDD scenarios to test execution
BDD-LOGIN-001: User Login Success → PASS (covered)
BDD-LOGIN-002: User Login Failure → PASS (covered)
BDD-LOGIN-003: Account Lockout → NOT TESTED (0% covered)
# Map contract endpoints to tests
POST /api/users → test_create_user_contract (100% covered)
GET /api/users/{id} → test_get_user_contract (100% covered)
PUT /api/users/{id} → NOT TESTED (0% covered)
DELETE /api/users/{id} → NOT TESTED (0% covered)
# REQ-USER-001: Username must be 3-20 alphanumeric characters
test_data = {
'valid': ['abc', 'user123', 'JohnDoe2025', 'a'.repeat(20)],
'boundary_min': 'ab', # Too short
'boundary_max': 'a'.repeat(21), # Too long
'invalid': ['ab', 'user@123', 'John Doe', '123', ''],
'edge_cases': ['aaa', 'zzz', '000', '999']
}
# CTR-USER-V1: User schema
test_data = {
'valid_user': {
'username': 'testuser',
'email': 'test@example.com',
'age': 25
},
'missing_required_field': {
'username': 'testuser'
# Missing email
},
'invalid_type': {
'username': 123, # Should be string
'email': 'test@example.com',
'age': 'twenty-five' # Should be integer
}
}
Required tools:
Read: Read SDD artifacts (BDD, REQ, CTR, SPEC)Write: Generate test filesEdit: Update existing testsBash: Execute test frameworks (pytest, pact)Glob: Find test files and artifactsGrep: Search for requirements and scenariosRequired libraries:
ACTION: Validate Given-When-Then format
SUGGEST: Correct scenario syntax
VERIFY: Scenario parseable by pytest-bdd
UPDATE: BDD document if needed
ACTION: Identify missing dependencies or invalid specifications
SUGGEST: Fix specification or install required libraries
VERIFY: Generated test is syntactically correct
UPDATE: Test template if needed
ACTION: Identify untested requirements/scenarios
SUGGEST: Generate additional test cases
VERIFY: New tests increase coverage
UPDATE: Traceability matrix
ACTION: Compare expected vs actual contract
SUGGEST: Update implementation or contract
VERIFY: Provider and consumer agree on contract
UPDATE: Contract version if breaking change
reports/coverage/logs/test-runs/