qa-test-data-engineering
Skill31 starsChanged 48 days agoMITView on GitHub
当需要批量构造测试数据(造 1000 条订单、准备各种状态的用户数据)、或者需要使用真实生产数据但需要脱敏时使用此技能。覆盖造数策略(API 造数/DB 直接构造/数据工厂)、脱敏方案(敏感字段识别/替换/掩码)、合规要求(GDPR/等保/个保法)和数据工厂架构设计。手工一条条造数据效率太低——测试数据工程的目标是让造数变成一键操作。 触发场景:造数、批量造数、数据构造、测试数据脱敏、测试数据合规、数据工厂、造1000条、造大量数据、环境数据不足需要批量构造时。 Use when the user asks about: bulk test data generation, production data masking and anonymization, data compliance, and data factory architecture.
In this repository50 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- qa-agent-testingSkill
- qa-ai-blindspot-compensationSkill
- qa-ai-context-engineeringSkill
- qa-ai-output-critiqueSkill
- qa-ai-prompt-strategySkill
- qa-api-testingSkill
- qa-boundary-deep-diveSkill
- qa-bug-lifecycleSkill
- qa-bug-reportingSkill
- qa-bug-root-cause-analysisSkill
- qa-ci-cd-testingSkill
- qa-code-review-for-testSkill
- qa-combination-strategySkill
- qa-critical-thinkingSkill
- qa-domain-modelingSkill
- qa-execution-observationSkill
- qa-expert-reviewSkill
- qa-exploratory-testingSkill
- qa-heuristic-checklistSkill
- qa-input-validationSkill
- qa-mobile-testingSkill
- qa-output-validationSkill
- qa-quality-metricsSkill
- qa-question-frameworkSkill
- qa-regression-testingSkill
- qa-release-risk-governanceSkill
- qa-req-deconstructionSkill
- qa-requirement-reviewSkill
- qa-retrospectiveSkill
- qa-risk-intuitionSkill
- qa-scenario-treeSkill
- qa-shift-leftSkill
- qa-shift-rightSkill
- qa-specialized-testingSkill
- qa-stakeholder-communicationSkill
- qa-state-transitionSkill
- qa-team-coachingSkill
- qa-tech-debt-managementSkill
- qa-tech-selectionSkill
- qa-testability-advocacySkill
- qa-test-automation-archSkill
- qa-test-case-designSkill
- qa-test-env-dataSkill
- qa-test-estimationSkill
- qa-test-leadershipSkill
- qa-test-reportingSkill
- qa-test-skillsSkill
- qa-test-strategy-designSkill
The file
Files
⚠️ 本技能单独使用效果有限,建议配合完整技能集(12 步工作流)使用。安装:npx skills add Kokxi/qa-test-skills
测试数据工程
核心原则
测试数据是测试的基础,好的数据管理让测试可重复、可追溯。
数据构造方法
手动构造
适用场景:
├─ 少量数据
├─ 复杂业务数据
├─ 一次性数据
└─ 调试用途
方法:
├─ 数据库直接插入
├─ 管理后台创建
├─ 接口调用创建
└─ 脚本批量创建数据工厂
适用场景:
├─ 批量数据
├─ 标准化数据
├─ 重复性数据
└─ 自动化测试
工具:
├─ Faker(Python/JS)
├─ Mockaroo(在线)
├─ Factory Bot(Ruby)
└─ 自建工厂类数据库脚本
-- 示例:用户数据构造
INSERT INTO users (username, email, phone, status, created_at)
VALUES
('testuser001', 'test1@example.com', '13800000001', 'active', NOW()),
('testuser002', 'test2@example.com', '13800000002', 'active', NOW()),
('testuser003', 'test3@example.com', '13800000003', 'inactive', NOW());API构造
# 示例:通过API构造订单数据
def create_test_order(user_id, product_id, quantity=1):
response = requests.post(
f"{BASE_URL}/orders",
json={
"user_id": user_id,
"product_id": product_id,
"quantity": quantity
},
headers={"Authorization": f"Bearer {token}"}
)
return response.json()["order_id"]加载时机
| 什么时候读 | 读哪个 |
| 做脱敏规则与实现时 | references/data-masking.md |
数据脱敏的完整内容已下沉至references/data-masking.md,避免每次触发都占用上下文。
数据清理
📌 本节与 qa-test-env-data「数据清理」内容同步,修改时请同步更新两处。
清理策略
├─ 按用例清理
│ ├─ 每个用例执行后清理
│ ├─ 优点:数据隔离好
│ └─ 缺点:效率低
│
├─ 按模块清理
│ ├─ 每个模块测试后清理
│ ├─ 优点:效率较高
│ └─ 缺点:隔离性一般
│
├─ 按批次清理
│ ├─ 每个批次测试后清理
│ ├─ 优点:效率高
│ └─ 缺点:隔离性差
│
└─ 定期清理
├─ 定期清理历史数据
├─ 优点:保持数据量可控
└─ 缺点:可能影响测试清理实现
⚠️ 安全警告:以下 SQL 清理示例仅适用于隔离的测试环境,切勿在生产数据库执行。 执行前必须确认:
- 目标数据库已确认为测试环境
- 先用
SELECT COUNT(*)预览受影响行数- 使用事务包裹(
BEGIN; DELETE ...; ROLLBACK;)做无害验证- 数据表有
is_test等明确测试标记字段- 如无把握,先向 DBA 确认清理范围
-- 示例:清理测试数据
-- 方法1:按时间清理
DELETE FROM orders WHERE created_at < DATE_SUB(NOW(), INTERVAL 7 DAY);
-- 方法2:按标记清理
DELETE FROM orders WHERE is_test = 1;
-- 方法3:按用户清理
DELETE FROM orders WHERE user_id IN (SELECT id FROM users WHERE is_test = 1);数据管理规范
命名规范
测试用户:
├─ 格式:test_[角色]_[序号]
├─ 示例:test_user_001, test_admin_001
└─ 标记:is_test = 1
测试数据:
├─ 格式:[类型]_test_[序号]
├─ 示例:order_test_001, product_test_001
└─ 标记:is_test = 1数据生命周期
├─ 构造:测试前准备数据
├─ 使用:测试中使用数据
├─ 验证:测试后验证数据
├─ 清理:测试后清理数据
└─ 归档:历史数据归档输出示例
构造100条用户注册测试数据 → 手动构造:录入10条核心数据(正常用户/边界值) → 数据工厂:编写SQL脚本批量生成80条 → API构造:调用注册接口自动化生成剩余
生产数据脱敏用于测试 → 脱敏规则:手机号(中间4位***)、身份证(生日****)、姓名(张三) → 脱敏实现:Docker部署Greenplum,配置脱敏策略执行
检查清单
测试数据管理完成后检查:
- 数据构造方法是否设计?
- 脱敏规则是否定义?
- 清理机制是否实现?
- 命名规范是否统一?
- 数据生命周期是否管理?
- 数据可追溯性是否保证?
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

