Skill站外收录 @skilllib/skill-2014279424349253633
integration-e2e-testing
面向业务价值与用户可感知结果的端到端及集成测试设计能力,通过行为驱动骨架、ROI量化评估、属性验证与可观测性校验,确保测试覆盖核心功能、数据一致性和关键错误路径,同时严格约束 mock 边界与执行条件。
测试与安全 AI 技能
Skills.MD
# Integration Test & E2E Test Design/Implementation Rules
## Test Types and Limits
| Type | Purpose | File Format | Limit |
|------|---------|-------------|-------|
| Integration Test | Component interaction verification | `*.int.test.ts` | 3 per feature |
| E2E Test | Critical user journey verification | `*.e2e.test.ts` | 1-2 per feature |
**Critical User Journey**: Features with revenue impact, legal requirements, or daily use by majority of users
## Behavior-First Principle
### Observability Check (All YES = Include)
| Check | Question | If NO |
|-------|----------|-------|
| Observable | Can user observe the result? | Exclude |
| System Context | Does it require integration of multiple components? | Exclude |
| Automatable | Can it run stably in CI environment? | Exclude |
### Include/Exclude Criteria
**Include**: Business logic accuracy, data integrity, user-visible features, error handling
**Exclude**: External live connections, performance metrics, implementation details, UI layout
## Skeleton Specification
### Required Comment Format
```typescript
// AC: "[Acceptance criteria original text]"
// ROI: [0-100] | Business Value: [0-10] | Frequency: [0-10]
// Behavior: [Trigger] -> [Process] -> [Observable Result]
// @category: core-functionality | integration | edge-case | ux | e2e
// @dependency: none | [component name] | full-system
// @complexity: low | medium | high
it.todo('[AC number]: [Test name]')
```
### Property Annotations
```typescript
// Property: `[Verification expression]`
// fast-check: fc.property(fc.[arbitrary], (input) => [invariant])
it.todo('[AC number]-property: [Invariant description]')
```
### ROI Calculation
```
ROI = (Business Value x Frequency + Legal Requirement x 10 + Defect Detection) / Total Cost
```
| Type | Total Cost | E2E Generation Condition |
|------|------------|-------------------------|
| Integration | 11 | - |
| E2E | 38 | ROI > 50 |
## Implementation Rules
### Property-Based Test Implementation
When Property annotation exists, fast-check library is required:
```typescript
import fc from 'fast-check'
it('AC2-property: Model name is always gemini-3-pro-image-preview', () => {
fc.assert(
fc.property(fc.string(), (prompt) => {
const result = client.generate(prompt)
return result.model === 'gemini-3-pro-image-preview'
})
)
})
```
**Requirements**:
- Write in `fc.assert(fc.property(...))` format
- Reflect skeleton's `// fast-check:` comment directly in implementation
- When failure case discovered, add as concrete unit test (regression prevention)
### Behavior Verification Implementation
**Behavior Description Verification Levels**:
| Step Type | Verification Target | Example |
|-----------|--------------------| --------|
| Trigger | Reproduce in Arrange | API failure -> mockResolvedValue({ ok: false }) |
| Process | Intermediate state or call | Function call, state change |
| Observable Result | Final output value | Return value, error message, log output |
**Pass Criteria**: Pass if "observable result" is verified as **return value or mock call argument** of test target
### Verification Item Determination Rules
| Skeleton State | Verification Item Determination Method |
|----------------|---------------------------------------|
| `// Verification items:` listed | Implement all listed items with expect |
| No `// Verification items:` | Derive from "observable result" in "Behavior" description |
| Both present | Prioritize verification items, use behavior as supplement |
### Integration Test Mock Boundaries
| Judgment Criteria | Mock | Actual |
|-------------------|------|--------|
| Part of test target? | No -> Can mock | Yes -> Actual required |
| Is call verification target of test? | No -> Can mock | Yes -> Actual or verifiable mock |
| External network communication? | Yes -> Mock required | No -> Actual recommended |
**Judgment Flow**:
1. External API (HTTP communication) -> Mock required
2. Component interaction under test -> Actual required
3. Log output verification needed -> Use verifiable mock (vi.fn())
4. Log output verification not needed -> Actual or ignore
### E2E Test Execution Conditions
- Execute only after all components are implemented
- Do not use mocks (`@dependency: full-system`)
## Review Criteria
### Skeleton and Implementation Consistency
| Check | Failure Condition |
|-------|-------------------|
| Property Verification | Property annotation exists but fast-check not used |
| Behavior Verification | No expect for "observable result" |
| Verification Item Coverage | Listed verification items not included in expect |
| Mock Boundary | Internal components mocked in integration test |
### Implementation Quality
| Check | Failure Condition |
|-------|-------------------|
| AAA Structure | Arrange/Act/Assert separation unclear |
| Independence | State sharing between tests, execution order dependency |
| Reproducibility | Depends on date/random, results vary |
| Readability | Test name and verification content don't match |
评论 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
举报「integration-e2e-testing」
举报信息仅审核团队可见,同一资产 24 小时内仅可举报一次