Operations 10 min read

One-Click Test Data Generation, Validation, and Cleanup with the 42nd Test Skill

The article walks through the pain of manually creating, validating, and cleaning test data for a user‑registration feature and shows how the test-data-manager Skill automates the entire workflow—producing dependency lists, SQL/API scripts, verification steps, and cleanup commands in minutes instead of hours.

Advanced AI Application Practice
Advanced AI Application Practice
Advanced AI Application Practice
One-Click Test Data Generation, Validation, and Cleanup with the 42nd Test Skill

The manual pain point

Testing a simple registration form with six fields (username, phone, captcha, password, confirm password, invite code) quickly turned into a two‑hour ordeal. The author had to insert an inviter user, resolve foreign‑key constraints for the invite code, request a captcha via an API, wait for it to expire, and later spend another half hour deleting leftover data that caused "phone already registered" and "invite code already used" errors.

Introducing test-data-manager Skill

The test-data-manager Skill is designed to handle the entire test‑data lifecycle. Given a functional description, it emits four files:

Dependency list – outlines which data must be created first.

Data‑generation script – executable SQL or API commands.

Validation script – checks that the generated data meets expectations.

Cleanup script – removes the data in reverse order.

For the registration example the Skill produces a four‑layer dependency diagram (inviter → invite code → captcha → registration), eliminating the need to manually inspect table structures.

Dependency diagram
Dependency diagram

Generated data‑generation scripts

The SQL part creates the inviter, a valid invite code, and a used invite code. Each INSERT includes a batch_id (e.g., tdm_20260726_004) that later enables precise cleanup.

-- 先造邀请人
INSERT INTO t_user (id, username, phone, status, invite_code,batch_id) VALUES (99001, 'inviter_base', '13800009901', 1, 'INV99001', 'tdm_20260726_004');

-- 再造有效邀请码
INSERT INTO t_invite_code (id, code, inviter_id, status, batch_id) VALUES (8001, 'INV_VALID_01', 99001, 1, 'tdm_20260726_004');

-- 再造一个已被使用过的邀请码
INSERT INTO t_invite_code (id, code, inviter_id, status, used_by, batch_id) VALUES (8002, 'INV_USED_01', 99001, 2, 99001, 'tdm_20260726_004');

The API part is a Python script that first calls the SMS service for a captcha and then submits the registration request, covering 13 test scenarios such as field boundary values and error conditions.

API test scenarios
API test scenarios

Validation script

After execution the validation script checks seven points: inviter insertion, invite‑code status, captcha expiration, successful user persistence, absence of dirty data in error scenarios, correct marking of used invite codes, and proper consumption of captchas. Each check outputs PASS or FAIL.

Cleanup script

The cleanup script deletes data in reverse dependency order, using the same batch_id to ensure only the current run’s data is removed. It performs soft deletes (setting is_deleted=1) and also clears related Redis caches and tokens.

DELETE FROM t_user WHERE batch_id = 'tdm_20260726_004';
DELETE FROM t_invite_code WHERE batch_id = 'tdm_20260726_004';
-- additional commands for captcha and token cleanup

Additional capabilities

Mixed data‑creation methods : pure SQL inserts, API calls, and shell scripts can be combined; the Skill orders execution automatically.

Multi‑environment support : a config.json defines DB URLs, table prefixes, and auth for dev, qa, and staging; run with -env qa to switch.

Up‑ and downstream integration : upstream test‑plan‑designer can feed data requirements; downstream testcase‑writer can reference the generated batch_id and IDs.

Cross‑platform usage : usable from WorkBuddy, Cursor, Trae, or the command line via generator.py. Five built‑in templates cover coupons, payments, orders, permissions, and state flows; custom needs are described directly in the functional description.

Impact

Manually creating and cleaning data for a medium‑complexity feature takes 1–2 hours plus 20–30 minutes for cleanup. Using the Skill reduces the whole process to about ten minutes, freeing time for additional exploratory testing, extra requirement reviews, or an earlier finish.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

PythonSQLautomationAPI testingQAtest data managementtest-data-manager
Advanced AI Application Practice
Written by

Advanced AI Application Practice

Advanced AI Application Practice

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.