$npx -y skills add anhtester/codex-testing-kit --skill test-data-generatorSkill sinh test data có cấu trúc, unique, traceable cho automation tests, bao gồm positive, negative, boundary và edge cases.
| 1 | # Test Data Generator |
| 2 | |
| 3 | Purpose: Generate reliable test data for automation tests. |
| 4 | |
| 5 | --- |
| 6 | |
| 7 | ## When to Use |
| 8 | |
| 9 | Use this skill when: |
| 10 | |
| 11 | - Creating test data for new test cases |
| 12 | - Generating boundary and edge case data |
| 13 | - Setting up data-driven tests |
| 14 | - Creating API request payloads |
| 15 | |
| 16 | --- |
| 17 | |
| 18 | ## Responsibilities |
| 19 | |
| 20 | Generate test data for: |
| 21 | |
| 22 | - Registration forms |
| 23 | - Login credentials |
| 24 | - Form submissions |
| 25 | - API payloads |
| 26 | - Search queries |
| 27 | - File uploads |
| 28 | |
| 29 | --- |
| 30 | |
| 31 | ## Data Rules |
| 32 | |
| 33 | All generated data must be: |
| 34 | |
| 35 | - **Unique** — No duplication within test suite |
| 36 | - **Deterministic** — Same seed produces same data (when needed) |
| 37 | - **Traceable** — Can identify which test generated it |
| 38 | |
| 39 | --- |
| 40 | |
| 41 | ## Unique Data Pattern |
| 42 | |
| 43 | Recommended format: |
| 44 | |
| 45 | ``` |
| 46 | <prefix>_<testName>_<timestamp> |
| 47 | ``` |
| 48 | |
| 49 | Examples: |
| 50 | |
| 51 | ``` |
| 52 | auto_register_20260402133000 |
| 53 | test_login_1712024100 |
| 54 | ``` |
| 55 | |
| 56 | --- |
| 57 | |
| 58 | ## Common Data Types |
| 59 | |
| 60 | |
| 61 | ``` |
| 62 | auto_<testName>_<timestamp>@test.com |
| 63 | ``` |
| 64 | Example: `auto_register_20260402@test.com` |
| 65 | |
| 66 | ### Username |
| 67 | ``` |
| 68 | user_<testName>_<timestamp> |
| 69 | ``` |
| 70 | Example: `user_login_20260402133000` |
| 71 | |
| 72 | ### Phone |
| 73 | ``` |
| 74 | Random 10-digit number starting with valid prefix |
| 75 | ``` |
| 76 | Example: `0912345678` |
| 77 | |
| 78 | ### Password |
| 79 | ``` |
| 80 | Mix of uppercase, lowercase, digits, special chars |
| 81 | ``` |
| 82 | Example: `Test@12345` |
| 83 | |
| 84 | --- |
| 85 | |
| 86 | ## Data Categories |
| 87 | |
| 88 | ### Positive Data (Happy Path) |
| 89 | - Valid format, within constraints |
| 90 | - All required fields filled |
| 91 | - Standard business values |
| 92 | |
| 93 | ### Negative Data |
| 94 | - Missing required fields |
| 95 | - Invalid format (wrong email, short password) |
| 96 | - Invalid characters |
| 97 | - Already existing values (duplicate check) |
| 98 | |
| 99 | ### Boundary Values |
| 100 | - Minimum length (e.g., 1 character) |
| 101 | - Maximum length (e.g., 255 characters) |
| 102 | - Min + 1, Max - 1 |
| 103 | - Empty string vs null |
| 104 | - Zero, negative numbers |
| 105 | |
| 106 | ### Edge Cases |
| 107 | - Unicode / special characters |
| 108 | - Very long strings |
| 109 | - SQL injection patterns (for security testing) |
| 110 | - HTML tags in text fields |
| 111 | - Leading/trailing whitespace |
| 112 | |
| 113 | --- |
| 114 | |
| 115 | ## Constraints |
| 116 | |
| 117 | Test data must: |
| 118 | |
| 119 | - Respect field validation rules (from DOM inspection) |
| 120 | - Match input format (date format, phone format) |
| 121 | - Avoid duplication across test runs |
| 122 | - Not contain real PII (personal data) |
| 123 | |
| 124 | --- |
| 125 | |
| 126 | ## Output Format |
| 127 | |
| 128 | Provide data in structured format: |
| 129 | |
| 130 | ```json |
| 131 | { |
| 132 | "positive": [ |
| 133 | { "email": "auto_tc01_20260402@test.com", "password": "Test@12345" } |
| 134 | ], |
| 135 | "negative": [ |
| 136 | { "email": "", "password": "Test@12345", "expectedError": "Email is required" }, |
| 137 | { "email": "invalid-email", "password": "Test@12345", "expectedError": "Invalid email format" } |
| 138 | ], |
| 139 | "boundary": [ |
| 140 | { "email": "a@b.co", "password": "12345678", "note": "Min length" } |
| 141 | ] |
| 142 | } |
| 143 | ``` |
| 144 | |
| 145 | --- |
| 146 | |
| 147 | ## Multi-Step Data Pipeline (Cross-Module) |
| 148 | |
| 149 | > Mở rộng cho bài toán: test data cần đi qua **nhiều modules nối tiếp** mới tạo ra được data hoàn chỉnh cho module cuối. |
| 150 | |
| 151 | ### Khi nào dùng |
| 152 | |
| 153 | - Tính năng đi qua chuỗi N modules (VD: Đối tác → Thanh toán → Thuế → Biên bản) |
| 154 | - Data module sau **phụ thuộc** output module trước (Reference fields) |
| 155 | - Cần tạo data thật trên hệ thống qua browser |
| 156 | |
| 157 | ### Data Chain Pattern |
| 158 | |
| 159 | ``` |
| 160 | Module 1 → Output: {id_1, code_1} |
| 161 | ↓ (Reference) |
| 162 | Module 2 → Input: {id_1} → Output: {id_2} |
| 163 | ↓ (Reference) |
| 164 | Module 3 → Input: {id_1, id_2} → Output: {id_3} |
| 165 | ↓ (Reference) |
| 166 | Module N → Input: {id_1..id_N-1} → Output: Final Result |
| 167 | ``` |
| 168 | |
| 169 | ### Field Classification |
| 170 | |
| 171 | | Loại field | Mô tả | Cách sinh data | |
| 172 | |-----------|-------|----------------| |
| 173 | | **Dimension field** | Giá trị thuộc chiều kết hợp trong ma trận | Lấy chính xác từ bộ combo — KHÔNG random | |
| 174 | | **Supporting field** | Bắt buộc nhưng không phải dimension | Random + unique + traceable | |
| 175 | | **Reference field** | ID/code từ output module trước | Copy từ output module trước trong chuỗi | |
| 176 | | **Computed field** | Tự tính từ formula/business rules | Tính theo formula — phải verify | |
| 177 | |
| 178 | ### Data Chain Tracing Format |
| 179 | |
| 180 | ``` |
| 181 | auto_combo{XX}_{module_short}_{timestamp} |
| 182 | ``` |
| 183 | |
| 184 | Ví dụ cho combo 01: |
| 185 | ``` |
| 186 | Module 1: partner_name = "auto_c01_partner_1712049200" |
| 187 | Module 2: payment_desc = "auto_c01_payment_1712049200" |
| 188 | Module 3: tax_note = "auto_c01_tax_1712049200" |
| 189 | → Có thể trace: combo 01 tạo ra những data nào ở mỗi module |
| 190 | ``` |
| 191 | |
| 192 | --- |
| 193 | |
| 194 | ## Combinatorial Data Generation |
| 195 | |
| 196 | > Sinh bộ data cho **ma trận kết hợp đa chiều** — mỗi bộ kết hợp = 1 bộ data hoàn chỉnh. |
| 197 | |
| 198 | ### Khi nào dùng |
| 199 | |
| 200 | - Đã có ma trận kết hợp (từ `$generate-cross-module-test-plan`) |
| 201 | - Cần sinh N bộ data tương ứng N bộ kết hợp |
| 202 | - Mỗi bộ data phải có expected output (template, formula, computed values) |
| 203 | |
| 204 | ### Combinatorial Data Structure |
| 205 | |
| 206 | ```json |
| 207 | { |
| 208 | "combination_id": "COMBO_01", |
| 209 | "dimensions": { |
| 210 | "D1": "value_from_matrix", |
| 211 | "D2": "value_from_matrix" |
| 212 | }, |
| 213 | "module_data": { |
| 214 | "module_1": { "field1": "...", "field2": "..." }, |
| 215 | "module_2": { "ref_from_module1": "...", "field3": "..." } |
| 216 | }, |
| 217 | "expected_output": { |
| 218 | "template": "EXPECTED_TEMPLATE_CODE", |
| 219 | "formula": "Amount × Rate", |
| 220 | "computed_values": { "total": 110000000 } |
| 221 | } |
| 222 | } |
| 223 | ``` |
| 224 | |
| 225 | ### Rules c |