@ngocsangairvds/vsaf 3.1.0 → 3.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,65 +1,85 @@
1
1
  ---
2
2
  name: vsaf-test
3
- description: Viết tài liệu testcase từ SRS. Dùng sau /vsaf-doc trước /vsaf-build. Test cases dựa trên spec, không dựa trên code hiện tại.
3
+ description: "Two modes: (1) generate testcases from SRS used after /vsaf-doc-srs and before /vsaf-build; (2) 'run' — execute tests, verify coverage, write results. Test cases are based on spec, not on code."
4
4
  ---
5
5
 
6
6
  # VSAF Test
7
7
 
8
- ## Mục tiêu
9
- Tạo tài liệu testcase coverage đầy đủ từ SRS để làm contract cho implementation.
8
+ ## Mode distinction
10
9
 
11
- ## Điều kiện tiên quyết
12
- - Đã chạy `/vsaf-doc`
13
- - file SRS trong `docs/project/srs/`
10
+ | Command | Mode | Goal |
11
+ |---------|------|------|
12
+ | `/vsaf-test <path/to/srs>` | **generate** | Generate testcase docs from SRS |
13
+ | `/vsaf-test run <path/to/testcases>` | **run** | Execute tests, verify coverage, write results file |
14
14
 
15
- ## Các bước thực hiện
15
+ ---
16
+
17
+ # Mode 1: Generate — Generate testcases from SRS
18
+
19
+ ## Goal
20
+ Create comprehensive testcase coverage documentation from SRS to serve as a contract for implementation.
21
+
22
+ ## Prerequisites
23
+ - Already ran `/vsaf-doc-prd` and `/vsaf-doc-srs`
24
+ - SRS file exists in `docs/project/srs/`
16
25
 
17
- ### Bước 1 — Sinh test cases từ SRS (BMAD qa)
18
- - Dùng skill `bmad-qa-generate-e2e-tests` với SRS file trong `docs/project/srs/` làm input
19
- - Test cases phải cover: happy path, edge cases, error cases, NFRs
20
- - Nguồn gốc: từ FRs/NFRs trong SRS — KHÔNG dựa trên implementation
26
+ ## Steps
21
27
 
22
- ### Bước 2Hunt edge cases (BMAD edge case hunter)
23
- - Dùng skill `bmad-review-edge-case-hunter` với SRS + testcases đã sinh
24
- - Tìm: boundary conditions, race conditions, empty/null inputs, overflow, concurrent access
25
- - Bổ sung test cases cho mọi edge case chưa cover
26
- - Mục tiêu: không có unhandled edge case nào lọt qua
28
+ ### Step 0Find existing test patterns (GitNexus)
29
+ - Use `gitnexus_query({query: "test patterns for <feature domain>"})` to see how the project currently tests
30
+ - Reference existing patterns to generate testcases consistent with the codebase
27
31
 
28
- ### Bước 3Đối chiếu coverage
29
- - So sánh test cases với FR/NFR trong SRS
30
- - Mỗi FR/NFR phải ít nhất 1 test case tương ứng
31
- - Ghi nhận gaps nếu
32
+ ### Step 1Generate test cases from SRS (BMAD qa)
33
+ - Use skill `bmad-qa-generate-e2e-tests` with the SRS file in `docs/project/srs/` as input
34
+ - Test cases must cover: happy path, edge cases, error cases, NFRs
35
+ - Source: from FRs/NFRs in SRS — NOT based on implementation
32
36
 
33
- ### Bước 4Xuất traceability matrix
34
- - Tạo bảng mapping `FR/NFR -> Testcase ID`
35
- - Mỗi testcase có: input, expected output, pass/fail criteria
37
+ ### Step 2Hunt edge cases (BMAD edge case hunter)
38
+ - Use skill `bmad-review-edge-case-hunter` with SRS + generated testcases
39
+ - Look for: boundary conditions, race conditions, empty/null inputs, overflow, concurrent access
40
+ - Add test cases for all uncovered edge cases
41
+ - Goal: no unhandled edge case slips through
36
42
 
37
- ### Bước 5Lưu tài liệu testcase
38
- - Lưu testcase vào `docs/project/testcases/[feature].md`
43
+ ### Step 3Cross-check coverage
44
+ - Compare test cases against FR/NFR in SRS
45
+ - Each FR/NFR must have at least 1 corresponding test case
46
+ - Document gaps if any
47
+
48
+ ### Step 4 — Export traceability matrix
49
+ - Create a mapping table `FR/NFR -> Testcase ID`
50
+ - Each testcase has: input, expected output, pass/fail criteria
51
+
52
+ ### Step 5 — Save testcase document
53
+ - Save testcases to `docs/project/testcases/[feature].md`
39
54
  - Format:
40
55
 
41
56
  ```markdown
42
57
  ## Testcases: [feature]
43
58
 
59
+ ### Traceability Matrix
60
+ | FR/NFR ID | Testcase IDs | Coverage |
61
+ |-----------|-------------|----------|
62
+ | FR-001 | TC-001, TC-002 | ✓ |
63
+
44
64
  ### Unit Tests
45
- | Test case | Input | Expected | Status |
46
- |-----------|-------|----------|--------|
47
- | ... | ... | ... | [ ] |
65
+ | Test case | FR/NFR | Input | Expected | Status |
66
+ |-----------|--------|-------|----------|--------|
67
+ | TC-001 | FR-001 | ... | ... | [ ] |
48
68
 
49
69
  ### Integration Tests
50
- | ... | ... | ... | [ ] |
70
+ | ... | ... | ... | ... | [ ] |
51
71
 
52
72
  ### Edge Cases
53
- | ... | ... | ... | [ ] |
73
+ | ... | ... | ... | ... | [ ] |
54
74
  ```
55
75
 
56
- ### Bước 6 — Implementation readiness gate (BMAD)
57
- - Dùng skill `bmad-check-implementation-readiness` để validate toàn bộ artifacts
58
- - Kiểm tra: SRS đầy đủ? Testcases cover hết FRs/NFRs? Architecture align?
59
- - Nếu **PASS**: hiển thị `✓ Implementation ready — proceed to /vsaf-build`
60
- - Nếu **FAIL**: liệt gaps cần fix trước khi build, KHÔNG cho tiếp
76
+ ### Step 6 — Implementation readiness gate (BMAD)
77
+ - Use skill `bmad-check-implementation-readiness` to validate all artifacts
78
+ - Check: SRS complete? Testcases cover all FRs/NFRs? Architecture aligned?
79
+ - If **PASS**: display `✓ Implementation ready — proceed to /vsaf-build`
80
+ - If **FAIL**: list gaps that need fixing before build, DO NOT proceed
61
81
 
62
- ### Bước 7 — Output cho user
82
+ ### Step 7 — Output to user
63
83
  ```
64
84
  ## Testcase Summary: [feature]
65
85
 
@@ -72,10 +92,108 @@ Files:
72
92
  - docs/project/testcases/[feature].md
73
93
 
74
94
  ## Next step
75
- [Nếu PASS]: Chạy /vsaf-build <path/to/srs> <path/to/testcases>
76
- [Nếu FAIL]: Fix gaps listed above, then re-run /vsaf-test
95
+ [If PASS]: Run /vsaf-build <path/to/prd> <path/to/srs> <path/to/testcases>
96
+ [If FAIL]: Fix gaps listed above, then re-run /vsaf-test
97
+ ```
98
+
99
+ ---
100
+
101
+ # Mode 2: Run — Execute tests + write results
102
+
103
+ ## Goal
104
+ Execute the full test suite, verify coverage matches changed code, write a structured results file. The results file is a required input for `/vsaf-ship`.
105
+
106
+ ## Prerequisites
107
+ - Already ran `/vsaf-build` — code implementation is complete
108
+ - Testcase file exists at `docs/project/testcases/[feature].md`
109
+
110
+ ## Steps
111
+
112
+ ### Step 1 — Re-read testcase file
113
+ - Re-read the testcase file, confirm all tests are present
114
+ - Cross-check with traceability matrix: each FR/NFR must have at least 1 test
115
+
116
+ ### Step 2 — Execute test suite
117
+ - Run all tests: unit + integration + e2e
118
+ - Use the project test runner (Maven/Gradle/npm/etc.)
119
+ - Record output for each test case
120
+
121
+ ### Step 3 — Map results back to FR/NFR
122
+ - Record pass/fail for each testcase
123
+ - Map results back to the traceability matrix: which FR/NFR passed, which have not
124
+
125
+ ### Step 4 — Verify coverage matches changed code (GitNexus)
126
+ - Run `gitnexus_detect_changes({scope: "compare", base_ref: "main"})`
127
+ - Compare the list of changed files/symbols with the list of tested files/symbols
128
+ - Flag any changed file/symbol that does NOT have test coverage
129
+
130
+ ### Step 5 — Architectural constraint check (GitNexus, optional)
131
+ - Run `gitnexus_shape_check` to validate no architectural constraints are violated
132
+ - Record constraint compliance results in the results file
133
+
134
+ ### Step 6 — Write results file
135
+ - Save results to `docs/project/testcases/[feature]-results.md`
136
+ - Format:
137
+
138
+ ```markdown
139
+ ## Test Results: [feature]
140
+ Date: [YYYY-MM-DD]
141
+
142
+ ### Summary
143
+ | Metric | Value |
144
+ |--------|-------|
145
+ | Total tests | [N] |
146
+ | Passed | [N] |
147
+ | Failed | [N] |
148
+ | Pass rate | [%] |
149
+ | FR/NFR coverage | [X/Y] ([%]) |
150
+ | Untested changes | [N files/symbols] |
151
+ | Shape check | [PASS / SKIP / FAIL] |
152
+
153
+ ### Results by FR/NFR
154
+ | FR/NFR ID | Tests | Passed | Failed | Status |
155
+ |-----------|-------|--------|--------|--------|
156
+ | FR-001 | 3 | 3 | 0 | ✓ |
157
+ | FR-002 | 2 | 1 | 1 | ✗ |
158
+
159
+ ### Failed Tests
160
+ | Test case | FR/NFR | Expected | Actual | Notes |
161
+ |-----------|--------|----------|--------|-------|
162
+
163
+ ### Untested Changes (from detect_changes)
164
+ | File/Symbol | Change type | Test coverage |
165
+ |-------------|------------|---------------|
166
+
167
+ ### Shape Check Results
168
+ [Output from gitnexus_shape_check, or "Skipped"]
169
+ ```
170
+
171
+ ### Step 7 — Ship gate
172
+ - **PASS** if:
173
+ - All FR/NFR have at least 1 test PASS
174
+ - No untested changes (or reason has been explained)
175
+ - Shape check has no violations
176
+ - **FAIL** if:
177
+ - Any FR/NFR has 0 passing tests -> **blocks ship**
178
+ - Untested changes detected without justification -> **blocks ship**
179
+ - Shape check violations -> **blocks ship**
180
+ - Display:
181
+
182
+ ```
183
+ ## Test Run Results: [feature]
184
+
185
+ - Pass rate: [X/Y] ([%])
186
+ - FR/NFR coverage: [X/Y] ([%])
187
+ - Untested changes: [N] — [CLEAR / BLOCKED]
188
+ - Shape check: [PASS / SKIP / FAIL]
189
+ - Ship gate: [PASS ✓ / FAIL ✗]
190
+
191
+ Results file: docs/project/testcases/[feature]-results.md
192
+
193
+ ## Next step
194
+ [If PASS]: Run /vsaf-ship
195
+ [If FAIL]: Fix failures above, then re-run /vsaf-test run
77
196
  ```
78
197
 
79
- ## Lưu ý
80
- - Không đánh dấu implementation done bước này
81
- - Nếu coverage thiếu cho FR/NFR quan trọng: quay lại cập nhật SRS trước khi build
198
+ ## Notes
199
+ - Results file is a required input for `/vsaf-ship` — no results = no ship