Skill站外收录 @skilllib/skill-2014279368917331969
test-design-techniques
基于边界值、等价类划分和组合逻辑系统化生成测试用例,覆盖数值边界、状态流转与多条件决策场景,在保证质量前提下显著减少冗余测试,适用于复杂业务规则的高效验证。
测试与安全 AI 技能
Skills.MD
# Test Design Techniques
<default_to_action>
When designing test cases systematically:
1. APPLY Boundary Value Analysis (test at min, max, edges)
2. USE Equivalence Partitioning (one test per partition)
3. CREATE Decision Tables (for complex business rules)
4. MODEL State Transitions (for stateful behavior)
5. REDUCE with Pairwise Testing (for combinations)
**Quick Design Selection:**
- Numeric ranges → BVA + EP
- Multiple conditions → Decision Tables
- Workflows → State Transition
- Many parameters → Pairwise Testing
**Critical Success Factors:**
- Systematic design finds more bugs with fewer tests
- Random testing is inefficient
- 40+ years of research backs these techniques
</default_to_action>
## Quick Reference Card
### When to Use
- Designing new test suites
- Optimizing existing tests
- Complex business rules
- Reducing test redundancy
### Technique Selection Guide
| Scenario | Technique |
|----------|-----------|
| **Numeric input ranges** | BVA + EP |
| **Multiple conditions** | Decision Tables |
| **Stateful workflows** | State Transition |
| **Many parameter combinations** | Pairwise |
| **All combinations critical** | Full Factorial |
---
## Boundary Value Analysis (BVA)
**Principle:** Bugs cluster at boundaries.
**Test at boundaries:**
- Minimum valid value
- Just below minimum (invalid)
- Just above minimum (valid)
- Maximum valid value
- Just above maximum (invalid)
```javascript
// Age field: 18-120 valid
const boundaryTests = [
{ input: 17, expected: 'invalid' }, // Below min
{ input: 18, expected: 'valid' }, // Min boundary
{ input: 19, expected: 'valid' }, // Above min
{ input: 119, expected: 'valid' }, // Below max
{ input: 120, expected: 'valid' }, // Max boundary
{ input: 121, expected: 'invalid' } // Above max
];
```
---
## Equivalence Partitioning (EP)
**Principle:** One test per equivalent class.
```javascript
// Discount rules:
// 1-10: No discount
// 11-100: 10% discount
// 101+: 20% discount
const partitionTests = [
{ quantity: -1, expected: 'invalid' }, // Invalid partition
{ quantity: 5, expected: 0 }, // Partition 1: 1-10
{ quantity: 50, expected: 0.10 }, // Partition 2: 11-100
{ quantity: 200, expected: 0.20 } // Partition 3: 101+
];
// 4 tests cover all behavior (vs 200+ if testing every value)
```
---
## Decision Tables
**Use for:** Complex business rules with multiple conditions.
```
Loan Approval Rules:
┌──────────────┬───────┬───────┬───────┬───────┬───────┐
│ Conditions │ R1 │ R2 │ R3 │ R4 │ R5 │
├──────────────┼───────┼───────┼───────┼───────┼───────┤
│ Age ≥ 18 │ Yes │ Yes │ Yes │ No │ Yes │
│ Credit ≥ 700 │ Yes │ Yes │ No │ Yes │ No │
│ Income ≥ 50k │ Yes │ No │ Yes │ Yes │ Yes │
├──────────────┼───────┼───────┼───────┼───────┼───────┤
│ Result │Approve│Approve│Reject │Reject │Reject │
└──────────────┴───────┴───────┴───────┴───────┴───────┘
// 5 tests cover all decision combinations
```
---
## State Transition Testing
**Model state changes:**
```
States: Logged Out → Logged In → Premium → Suspended
Valid Transitions:
- Login: Logged Out → Logged In
- Upgrade: Logged In → Premium
- Payment Fail: Premium → Suspended
- Logout: Any → Logged Out
Invalid Transitions to Test:
- Logged Out → Premium (should reject)
- Suspended → Premium (should reject)
```
```javascript
test('cannot upgrade without login', async () => {
const result = await user.upgrade(); // While logged out
expect(result.error).toBe('Login required');
});
```
---
## Pairwise (Combinatorial) Testing
**Problem:** All combinations explode exponentially.
```javascript
// Parameters:
// Browser: Chrome, Firefox, Safari (3)
// OS: Windows, Mac, Linux (3)
// Screen: Desktop, Tablet, Mobile (3)
// All combinations: 3 × 3 × 3 = 27 tests
// Pairwise: 9 tests cover all pairs
const pairwiseTests = [
{ browser: 'Chrome', os: 'Windows', screen: 'Desktop' },
{ browser: 'Chrome', os: 'Mac', screen: 'Tablet' },
{ browser: 'Chrome', os: 'Linux', screen: 'Mobile' },
{ browser: 'Firefox', os: 'Windows', screen: 'Tablet' },
{ browser: 'Firefox', os: 'Mac', screen: 'Mobile' },
{ browser: 'Firefox', os: 'Linux', screen: 'Desktop' },
{ browser: 'Safari', os: 'Windows', screen: 'Mobile' },
{ browser: 'Safari', os: 'Mac', screen: 'Desktop' },
{ browser: 'Safari', os: 'Linux', screen: 'Tablet' }
];
// Each pair appears at least once
```
---
## Agent-Driven Test Design
```typescript
// Auto-generate BVA tests
await Task("Generate BVA Tests", {
field: 'age',
dataType: 'integer',
constraints: { min: 18, max: 120 }
}, "qe-test-generator");
// Returns: 6 boundary test cases
// Auto-generate pairwise tests
await Task("Generate Pairwise Tests", {
parameters: {
browser: ['Chrome', 'Firefox', 'Safari'],
os: ['Windows', 'Mac', 'Linux'],
screen: ['Desktop', 'Tablet', 'Mobile']
}
}, "qe-test-generator");
// Returns: 9-12 tests (vs 27 full combination)
```
---
## Agent Coordination Hints
### Memory Namespace
```
aqe/test-design/
├── bva-analysis/* - Boundary value tests
├── partitions/* - Equivalence partitions
├── decision-tables/* - Decision table tests
└── pairwise/* - Combinatorial reduction
```
### Fleet Coordination
```typescript
const designFleet = await FleetManager.coordinate({
strategy: 'systematic-test-design',
agents: [
'qe-test-generator', // Apply design techniques
'qe-coverage-analyzer', // Analyze coverage
'qe-quality-analyzer' // Assess test quality
],
topology: 'sequential'
});
```
---
## Related Skills
- [agentic-quality-engineering](../agentic-quality-engineering/) - Agent-driven testing
- [risk-based-testing](../risk-based-testing/) - Prioritize by risk
- [mutation-testing](../mutation-testing/) - Validate test effectiveness
---
## Remember
**Systematic design > Random testing.** 40+ years of research shows these techniques find more bugs with fewer tests than ad-hoc approaches.
**Combine techniques for comprehensive coverage.** BVA for boundaries, EP for partitions, decision tables for rules, pairwise for combinations.
**With Agents:** `qe-test-generator` applies these techniques automatically, generating optimal test suites with maximum coverage and minimum redundancy. Agents identify boundaries, partitions, and combinations from code analysis.
评论 0
还没有评论,来抢沙发。
相关内容
同类或同场景的收录内容
building-with-kafka-strimzi
在 Kubernetes 上构建基于 Apache Kafka 的事件驱动系统,支持高可靠的消息传递、事务性处理与精确一次语义,结合 Strimzi 运营商实现集群自动化管理,利用 Schema Registry 保障事件模式演进,适用于微服务间解耦通信与实时数据流处理场景。
站外数据与分析
609 0.0
personal-tool-builder
专注于从个人真实痛点出发快速构建实用工具,涵盖命令行程序、本地优先应用和自动化脚本的开发与演进,强调先满足自身需求再逐步扩展,通过持续自用打磨功能,避免过度设计,确保工具简洁有效且长期可维护。
站外商业与营销
196 0.0
threejs-lighting
实现三维场景中的光照与阴影控制,支持多种光源类型及环境光照明,提供从基础布光到高级阴影优化的完整方案,适用于需要真实感渲染或性能平衡的可视化项目。
站外效率工具
442 0.0
aggregation-helper
提供数据聚合场景的自动化辅助能力,涵盖 SQL 查询编写、统计分析建模、可视化方案设计及商业智能配置,支持从需求理解到生产级代码生成的全流程指导。
站外效率工具数据与分析
217 0.0
举报「test-design-techniques」
举报信息仅审核团队可见,同一资产 24 小时内仅可举报一次