sdtk-spec-kit 0.9.2 → 0.10.0
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.
- package/README.md +1 -1
- package/assets/manifest/toolkit-bundle.manifest.json +200 -25
- package/assets/manifest/toolkit-bundle.sha256.txt +47 -12
- package/assets/toolkit/toolkit/AGENTS.md +1 -1
- package/assets/toolkit/toolkit/SDTK_TOOLKIT.md +7 -3
- package/assets/toolkit/toolkit/runtimes/claude/CLAUDE_TEMPLATE.md +3 -0
- package/assets/toolkit/toolkit/scripts/install-claude-skills.ps1 +28 -0
- package/assets/toolkit/toolkit/scripts/install-codex-skills.ps1 +18 -0
- package/assets/toolkit/toolkit/skills/sdtk-orchestrator/SKILL.md +2 -0
- package/assets/toolkit/toolkit/skills/sdtk-qa/SKILL.md +1 -1
- package/assets/toolkit/toolkit/skills/sdtk-smoke-test-spec/SKILL.md +69 -0
- package/assets/toolkit/toolkit/skills/sdtk-smoke-test-spec/scripts/test_validate_smoke_test.py +58 -0
- package/assets/toolkit/toolkit/skills/sdtk-smoke-test-spec/scripts/validate_smoke_test.py +152 -0
- package/assets/toolkit/toolkit/skills/sdtk-test-case-xlsx/SKILL.md +297 -0
- package/assets/toolkit/toolkit/skills/sdtk-test-case-xlsx/prompts/agent_brief_template.md +59 -0
- package/assets/toolkit/toolkit/skills/sdtk-test-case-xlsx/scripts/check_coverage.py +50 -0
- package/assets/toolkit/toolkit/skills/sdtk-test-case-xlsx/scripts/extract_sources.py +224 -0
- package/assets/toolkit/toolkit/skills/sdtk-test-case-xlsx/scripts/merge_parts.py +78 -0
- package/assets/toolkit/toolkit/skills/sdtk-test-case-xlsx/scripts/render_testcase.py +421 -0
- package/assets/toolkit/toolkit/skills/sdtk-test-case-xlsx/scripts/template_set.py +57 -0
- package/assets/toolkit/toolkit/skills/sdtk-test-case-xlsx/scripts/test_write_results.py +89 -0
- package/assets/toolkit/toolkit/skills/sdtk-test-case-xlsx/scripts/write_results.py +126 -0
- package/assets/toolkit/toolkit/skills/sdtk-xlsx-safe-edit/SKILL.md +146 -0
- package/assets/toolkit/toolkit/skills/sdtk-xlsx-safe-edit/scripts/pictures.py +68 -0
- package/assets/toolkit/toolkit/skills/sdtk-xlsx-safe-edit/scripts/test_pictures.py +55 -0
- package/assets/toolkit/toolkit/skills/sdtk-xlsx-safe-edit/scripts/xlsafe.py +137 -0
- package/assets/toolkit/toolkit/skills/sdtk-xlsx-safe-edit/scripts/xlsx_xml_edit.py +153 -0
- package/assets/toolkit/toolkit/skills/skills.catalog.yaml +76 -0
- package/assets/toolkit/toolkit/skills-claude/orchestrator/SKILL.md +1 -1
- package/assets/toolkit/toolkit/skills-claude/qa/SKILL.md +1 -1
- package/assets/toolkit/toolkit/skills-claude/smoke-test-spec/SKILL.md +66 -0
- package/assets/toolkit/toolkit/skills-claude/test-case-xlsx/SKILL.md +294 -0
- package/assets/toolkit/toolkit/skills-claude/xlsx-safe-edit/SKILL.md +143 -0
- package/assets/toolkit/toolkit/templates/README.md +8 -1
- package/assets/toolkit/toolkit/templates/smoke-test/PROFILE_TEMPLATE.md +36 -0
- package/assets/toolkit/toolkit/templates/smoke-test/vi-default/AUTHORING_RULES.md +32 -0
- package/assets/toolkit/toolkit/templates/smoke-test/vi-default/SMOKE_TEST_TEMPLATE.md +147 -0
- package/assets/toolkit/toolkit/templates/smoke-test/vi-default/TEMPLATE.md +25 -0
- package/assets/toolkit/toolkit/templates/test-case-xlsx/PROFILE_TEMPLATE.md +78 -0
- package/assets/toolkit/toolkit/templates/test-case-xlsx/ja-default/TEMPLATE.md +28 -0
- package/assets/toolkit/toolkit/templates/test-case-xlsx/ja-default/viewpoints/README.md +73 -0
- package/assets/toolkit/toolkit/templates/test-case-xlsx/ja-default/viewpoints/_template.xlsx +0 -0
- package/assets/toolkit/toolkit/templates/test-case-xlsx/ja-default/viewpoints/common/common.xlsx +0 -0
- package/assets/toolkit/toolkit/templates/test-case-xlsx/ja-default/viewpoints/platform/mobile_app.xlsx +0 -0
- package/assets/toolkit/toolkit/templates/test-case-xlsx/ja-default/viewpoints/platform/smartphone_web.xlsx +0 -0
- package/assets/toolkit/toolkit/templates/test-case-xlsx/ja-default/viewpoints/platform/web.xlsx +0 -0
- package/assets/toolkit/toolkit/templates/test-case-xlsx/ja-default/viewpoints/platform/windows_app.xlsx +0 -0
- package/assets/toolkit/toolkit/templates/test-case-xlsx/ja-default//343/203/206/343/202/271/343/203/210/344/273/225/346/247/230/346/233/270/344/275/234/346/210/220/343/203/253/343/203/274/343/203/253.md +514 -0
- package/assets/toolkit/toolkit/templates/test-case-xlsx/ja-default//343/203/206/343/202/271/343/203/210/344/273/225/346/247/230/346/233/270/351/233/233/345/236/213.xlsx +0 -0
- package/package.json +1 -1
- package/src/lib/scope.js +4 -2
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Validate + render a bilingual (JA/VI) test specification from a JSON source.
|
|
3
|
+
|
|
4
|
+
Usage (from repo root):
|
|
5
|
+
python toolkit/skills/sdtk-test-case-xlsx/scripts/render_testcase.py <spec.json> \
|
|
6
|
+
[--md <out.md>] [--xlsx <out.xlsx>] [--check-only]
|
|
7
|
+
|
|
8
|
+
The JSON source (see SKILL.md "Step 4") holds only what the agent writes
|
|
9
|
+
(green columns). This script does the mechanical parts of テスト仕様書作成ルール.md:
|
|
10
|
+
- sorts cases per sheet by band order (§4-B) then 正常系→異常系→境界値 (§4-D), stable
|
|
11
|
+
- numbers No from 1 per sheet (§4-A), fills 中分類 with the sheet's screen name (§4-C)
|
|
12
|
+
- leaves human columns I..M / H..I / yellow cover fields empty (§6, §10)
|
|
13
|
+
- runs the §11 self-check and exits non-zero on any ERROR
|
|
14
|
+
- optional spec["db_prefixes"] (profile): every non-"no DB" 期待結果(DB) line must start with one of them
|
|
15
|
+
- --xlsx: fills テスト仕様書雛型.xlsx (copy 00_雛型 + setup_sheet() of §8)
|
|
16
|
+
"""
|
|
17
|
+
import argparse
|
|
18
|
+
import json
|
|
19
|
+
import os
|
|
20
|
+
import re
|
|
21
|
+
import sys
|
|
22
|
+
|
|
23
|
+
SKILL_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
24
|
+
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
25
|
+
import template_set # noqa: E402
|
|
26
|
+
TEMPLATE = None # set by main() from the template set (spec "template_set" / --template-dir)
|
|
27
|
+
|
|
28
|
+
# §4-B: band -> 大分類 in order. Bilingual label for the .md output.
|
|
29
|
+
BANDS = [
|
|
30
|
+
(10, [("画面レイアウト", "Bố cục màn hình")]),
|
|
31
|
+
(20, [("各種コントロール", "Các control")]),
|
|
32
|
+
(30, [("登録", "Đăng ký"), ("検索・絞り込み", "Tìm kiếm・Lọc"), ("編集", "Chỉnh sửa"),
|
|
33
|
+
("削除", "Xóa"), ("復元", "Khôi phục")]),
|
|
34
|
+
(40, [("CSV出力", "Xuất CSV"), ("帳票出力", "Xuất biểu mẫu"), ("印刷", "In")]),
|
|
35
|
+
(50, [("権限・認可", "Phân quyền・Ủy quyền"), ("排他制御", "Kiểm soát đồng thời"),
|
|
36
|
+
("外部連携・I/F", "Liên kết ngoài・I/F")]),
|
|
37
|
+
]
|
|
38
|
+
MINORS = [("正常系", "Bình thường"), ("異常系", "Bất thường"), ("境界値", "Giá trị biên")]
|
|
39
|
+
NO_DB = "-(画面表示のみのため確認不要)"
|
|
40
|
+
NO_DB_VI = "- (chỉ kiểm tra hiển thị màn hình, không cần kiểm tra DB)"
|
|
41
|
+
# §4-F/G, §10: phrases that make a case unverifiable
|
|
42
|
+
BANNED = ["正しく", "適切に", "問題なく", "適当な値", "任意の文字列", "正しく入力", "仕様どおり"]
|
|
43
|
+
QUOTED = re.compile(r"「[^」]*」")
|
|
44
|
+
SHEET_NAME_BAD =re.compile(r"[:\\/?*\[\]]")
|
|
45
|
+
SHEET_NAME_FMT = re.compile(r"^\d{2}_.+")
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
if hasattr(sys.stdout, "reconfigure"):
|
|
49
|
+
sys.stdout.reconfigure(encoding="utf-8") # Windows console (cp1252) cannot print JA text
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def fail(errors, msg):
|
|
53
|
+
errors.append("ERROR " + msg)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def band_table(extra_majors):
|
|
57
|
+
"""Return ordered list of (ja, vi) majors, with extra majors appended at the END of their band (§4-B)."""
|
|
58
|
+
order = []
|
|
59
|
+
for band, majors in BANDS:
|
|
60
|
+
order.extend(majors)
|
|
61
|
+
for ex in extra_majors:
|
|
62
|
+
if ex["band"] == band:
|
|
63
|
+
order.append((ex["ja"], ex["vi"]))
|
|
64
|
+
return order
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def bi(obj, key="ja"):
|
|
68
|
+
if isinstance(obj, dict):
|
|
69
|
+
return obj.get(key, "") or ""
|
|
70
|
+
return obj if key == "ja" else ""
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def validate(spec):
|
|
74
|
+
errors, warnings = [], []
|
|
75
|
+
extra = spec.get("extra_majors", [])
|
|
76
|
+
for ex in extra:
|
|
77
|
+
if ex.get("band") not in [b for b, _ in BANDS]:
|
|
78
|
+
fail(errors, f"extra_majors {ex}: band must be one of 10/20/30/40/50")
|
|
79
|
+
majors = band_table(extra)
|
|
80
|
+
prefixes = tuple(spec.get("db_prefixes", []))
|
|
81
|
+
major_names = [m[0] for m in majors]
|
|
82
|
+
minor_names = [m[0] for m in MINORS]
|
|
83
|
+
for key in ("system_name", "subsystem_name", "function_name", "related_specs"):
|
|
84
|
+
if not bi(spec.get("cover", {}).get(key)):
|
|
85
|
+
fail(errors, f"cover.{key} is empty")
|
|
86
|
+
sheet_names = set()
|
|
87
|
+
for sh in spec["sheets"]:
|
|
88
|
+
name = sh["name"]
|
|
89
|
+
if len(name) > 31 or SHEET_NAME_BAD.search(name) or not SHEET_NAME_FMT.match(name):
|
|
90
|
+
fail(errors, f"sheet name '{name}': must be 2-digit_画面名, ≤31 chars, no : \\ / ? * [ ]")
|
|
91
|
+
if name.split("_", 1)[1] not in (sh["screen_name"], sh["screen_name"].removesuffix("画面")):
|
|
92
|
+
warnings.append(f"WARN sheet '{name}': name after No should equal screen_name '{sh['screen_name']}'")
|
|
93
|
+
sheet_names.add(name)
|
|
94
|
+
if not sh.get("screen_types"):
|
|
95
|
+
fail(errors, f"sheet '{name}': screen_types (§7.2) is required")
|
|
96
|
+
if not sh["cases"]:
|
|
97
|
+
fail(errors, f"sheet '{name}': no cases")
|
|
98
|
+
for i, c in enumerate(sh["cases"]):
|
|
99
|
+
where = f"sheet '{name}' case#{i + 1} ({bi(c.get('screen'))[:30]}…)"
|
|
100
|
+
if c.get("major") not in major_names:
|
|
101
|
+
fail(errors, f"{where}: 大分類 '{c.get('major')}' not in band table / extra_majors")
|
|
102
|
+
if c.get("minor") not in minor_names:
|
|
103
|
+
fail(errors, f"{where}: 小分類 '{c.get('minor')}' must be 正常系/異常系/境界値")
|
|
104
|
+
if not c.get("spec"):
|
|
105
|
+
fail(errors, f"{where}: 関連仕様書ID・画面ID is empty")
|
|
106
|
+
for fld in ("steps", "screen", "db"):
|
|
107
|
+
for lang in ("ja", "vi"):
|
|
108
|
+
v = c.get(fld, {}).get(lang)
|
|
109
|
+
if fld == "db" and lang == "vi" and bi(c.get("db")).strip() == NO_DB:
|
|
110
|
+
continue # renderer fills NO_DB_VI
|
|
111
|
+
if not v:
|
|
112
|
+
fail(errors, f"{where}: {fld}.{lang} is empty")
|
|
113
|
+
if isinstance(c.get("steps", {}).get("ja"), list) and isinstance(c["steps"].get("vi"), list):
|
|
114
|
+
if len(c["steps"]["ja"]) != len(c["steps"]["vi"]):
|
|
115
|
+
fail(errors, f"{where}: steps.ja and steps.vi have different number of steps")
|
|
116
|
+
else:
|
|
117
|
+
fail(errors, f"{where}: steps.ja / steps.vi must be lists of strings")
|
|
118
|
+
db = bi(c.get("db"))
|
|
119
|
+
if db.strip() in ("-", "-", "ー", "なし"):
|
|
120
|
+
fail(errors, f"{where}: 期待結果(DB) must be '{NO_DB}' when no DB check (§4-H)")
|
|
121
|
+
elif prefixes and db.strip() != NO_DB:
|
|
122
|
+
bad = [ln for ln in db.splitlines() if ln.strip() and not ln.lstrip().startswith(prefixes)]
|
|
123
|
+
if bad:
|
|
124
|
+
fail(errors, f"{where}: 期待結果(DB) line '{bad[0][:40]}' must start with one of {list(prefixes)}")
|
|
125
|
+
text_ja = " ".join(c.get("steps", {}).get("ja", []) or []) + bi(c.get("screen")) + db
|
|
126
|
+
text_ja = QUOTED.sub("", text_ja) # exact UI text in 「」 may legitimately contain 正しく etc.
|
|
127
|
+
for w in BANNED:
|
|
128
|
+
if w in text_ja:
|
|
129
|
+
fail(errors, f"{where}: banned vague phrase '{w}'")
|
|
130
|
+
minors = {c.get("minor") for c in sh["cases"]}
|
|
131
|
+
if "異常系" not in minors or "境界値" not in minors:
|
|
132
|
+
warnings.append(f"WARN sheet '{name}': 異常系 or 境界値 missing — suspect omissions (§4-D)")
|
|
133
|
+
if len(sh["cases"]) > 500:
|
|
134
|
+
fail(errors, f"sheet '{name}': more than 500 rows (template rows 2..501)")
|
|
135
|
+
for d in spec.get("data_prep", []):
|
|
136
|
+
if d.get("target_screen") != "共通" and d.get("target_screen") not in sheet_names:
|
|
137
|
+
fail(errors, f"data_prep target_screen '{d.get('target_screen')}' must be 共通 or a sheet name")
|
|
138
|
+
return errors, warnings
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def sorted_cases(sh, majors):
|
|
142
|
+
idx_major = {m[0]: i for i, m in enumerate(majors)}
|
|
143
|
+
idx_minor = {m[0]: i for i, m in enumerate(MINORS)}
|
|
144
|
+
return sorted(sh["cases"], key=lambda c: (idx_major[c["major"]], idx_minor[c["minor"]]))
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def md_cell(s):
|
|
148
|
+
return str(s).replace("|", "\\|").replace("\n", "<br>")
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def bi_cell(ja, vi):
|
|
152
|
+
ja, vi = md_cell(ja), md_cell(vi)
|
|
153
|
+
return f"{ja}<br>🇻🇳 {vi}" if vi else ja
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def steps_cell(steps):
|
|
157
|
+
ja = "<br>".join(f"{i}. {md_cell(s)}" for i, s in enumerate(steps["ja"], 1))
|
|
158
|
+
vi = "<br>".join(f"{i}. {md_cell(s)}" for i, s in enumerate(steps["vi"], 1))
|
|
159
|
+
return f"{ja}<br>🇻🇳<br>{vi}"
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
def render_md(spec):
|
|
163
|
+
majors = band_table(spec.get("extra_majors", []))
|
|
164
|
+
major_vi = dict(majors)
|
|
165
|
+
minor_vi = dict(MINORS)
|
|
166
|
+
cov = spec["cover"]
|
|
167
|
+
out = []
|
|
168
|
+
w = out.append
|
|
169
|
+
w(f"# テスト仕様書 — {bi(cov['function_name'])}")
|
|
170
|
+
w(f"# Đặc tả kiểm thử — {bi(cov['function_name'], 'vi')}")
|
|
171
|
+
w("")
|
|
172
|
+
w("> 本書は `テスト仕様書雛型.xlsx` の構成(表紙 / テストデータ準備 / 画面別チェック項目シート)を Markdown で再現したもの。"
|
|
173
|
+
"列構成・並び順は `テスト仕様書作成ルール.md` に従う。空欄の列・項目は人が記入する。 ")
|
|
174
|
+
w("> Tài liệu này tái hiện cấu trúc của `テスト仕様書雛型.xlsx` (Trang bìa / Chuẩn bị dữ liệu test / Sheet check theo từng màn hình) "
|
|
175
|
+
"dưới dạng Markdown. Cấu trúc cột và thứ tự tuân theo `テスト仕様書作成ルール.md`. Các cột/mục để trống do người thực hiện điền.")
|
|
176
|
+
w("")
|
|
177
|
+
w("## 目次 / Mục lục")
|
|
178
|
+
w("")
|
|
179
|
+
w("- [表紙 / Trang bìa](#表紙--trang-bìa)")
|
|
180
|
+
w("- [テストデータ準備 / Chuẩn bị dữ liệu test](#テストデータ準備--chuẩn-bị-dữ-liệu-test)")
|
|
181
|
+
for sh in spec["sheets"]:
|
|
182
|
+
w(f"- {sh['name']} — {sh['screen_name']} / {sh.get('screen_name_vi', '')}")
|
|
183
|
+
if spec.get("report"):
|
|
184
|
+
w("- [作成報告 / Báo cáo khi tạo](#作成報告--báo-cáo-khi-tạo)")
|
|
185
|
+
w("")
|
|
186
|
+
|
|
187
|
+
# ---- 表紙
|
|
188
|
+
w("## 表紙 / Trang bìa")
|
|
189
|
+
w("")
|
|
190
|
+
w("| 項目 / Mục | 内容 / Nội dung | 項目 / Mục | 内容 / Nội dung |")
|
|
191
|
+
w("|---|---|---|---|")
|
|
192
|
+
rows = [
|
|
193
|
+
(("システム名", "Tên hệ thống"), cov["system_name"], ("版数", "Phiên bản")),
|
|
194
|
+
(("サブシステム名", "Tên hệ thống con"), cov["subsystem_name"], ("テスト環境", "Môi trường test")),
|
|
195
|
+
(("機能名/画面名", "Tên chức năng / màn hình"), cov["function_name"], ("作成者", "Người tạo")),
|
|
196
|
+
(("関連仕様書", "Tài liệu đặc tả liên quan"), cov["related_specs"], ("作成日", "Ngày tạo")),
|
|
197
|
+
(("備考", "Ghi chú"), None, ("更新者", "Người cập nhật")),
|
|
198
|
+
(("テスト実施期間", "Thời gian thực hiện test"), None, ("更新日", "Ngày cập nhật")),
|
|
199
|
+
]
|
|
200
|
+
for (lj, lv), val, (rj, rv) in rows:
|
|
201
|
+
v = bi_cell(bi(val), bi(val, "vi")) if val else ""
|
|
202
|
+
w(f"| {lj}<br>{lv} | {v} | {rj}<br>{rv} | |")
|
|
203
|
+
w("")
|
|
204
|
+
w("### 改訂履歴(人が記入) / Lịch sử sửa đổi (người thực hiện điền)")
|
|
205
|
+
w("")
|
|
206
|
+
w("| 版数 / Phiên bản | 改訂日 / Ngày sửa | 改訂者 / Người sửa | 改訂内容 / Nội dung sửa |")
|
|
207
|
+
w("|---|---|---|---|")
|
|
208
|
+
for _ in range(3):
|
|
209
|
+
w("| | | | |")
|
|
210
|
+
w("")
|
|
211
|
+
w("### 画面別テスト結果サマリ / Tổng hợp kết quả test theo màn hình")
|
|
212
|
+
w("")
|
|
213
|
+
w("> 総数はケース件数(Excel版では自動集計)。OK〜消化率は実施後に人が集計する。 ")
|
|
214
|
+
w("> 総数 = số test case (bản Excel tự động tính). OK〜消化率 do người thực hiện tổng hợp sau khi test.")
|
|
215
|
+
w("")
|
|
216
|
+
w("| シート名 / Tên sheet | 担当者 / Người phụ trách | 総数 / Tổng | OK | NG | 保留 | 対象外 | 未実施 | 消化率 |")
|
|
217
|
+
w("|---|---|---|---|---|---|---|---|---|")
|
|
218
|
+
total = 0
|
|
219
|
+
for sh in spec["sheets"]:
|
|
220
|
+
n = len(sh["cases"])
|
|
221
|
+
total += n
|
|
222
|
+
w(f"| {sh['name']} | | {n} | | | | | | |")
|
|
223
|
+
w(f"| 合計 / Tổng cộng | | {total} | | | | | | |")
|
|
224
|
+
w("")
|
|
225
|
+
w(f"テストデータ準備 項目数 / Số mục chuẩn bị dữ liệu test: **{len(spec.get('data_prep', []))}**")
|
|
226
|
+
w("")
|
|
227
|
+
w("### 大分類 × 小分類 件数 / Số case theo Phân loại lớn × Phân loại nhỏ")
|
|
228
|
+
w("")
|
|
229
|
+
w("| シート名 / Tên sheet | 大分類 / Phân loại lớn | 正常系 | 異常系 | 境界値 | 計 |")
|
|
230
|
+
w("|---|---|---|---|---|---|")
|
|
231
|
+
for sh in spec["sheets"]:
|
|
232
|
+
for mj, mv in majors:
|
|
233
|
+
cnt = [sum(1 for c in sh["cases"] if c["major"] == mj and c["minor"] == mn) for mn, _ in MINORS]
|
|
234
|
+
if sum(cnt):
|
|
235
|
+
w(f"| {sh['name']} | {mj} / {mv} | {cnt[0]} | {cnt[1]} | {cnt[2]} | {sum(cnt)} |")
|
|
236
|
+
w("")
|
|
237
|
+
|
|
238
|
+
# ---- テストデータ準備
|
|
239
|
+
w("## テストデータ準備 / Chuẩn bị dữ liệu test")
|
|
240
|
+
w("")
|
|
241
|
+
w("> 上から順に準備する。「準備完了」「備考」は人が記入する。 ")
|
|
242
|
+
w("> Chuẩn bị theo thứ tự từ trên xuống. Cột 「準備完了」「備考」 do người thực hiện điền.")
|
|
243
|
+
w("")
|
|
244
|
+
w("| No | 対象画面<br>Màn hình | 分類<br>Phân loại | 対象(テーブル/マスタ/画面)<br>Đối tượng | 準備するデータ・状態<br>Dữ liệu・trạng thái cần chuẩn bị"
|
|
245
|
+
" | 件数・値の例<br>Số lượng・giá trị ví dụ | 準備方法<br>Cách chuẩn bị | 準備完了<br>Hoàn tất | 備考<br>Ghi chú |")
|
|
246
|
+
w("|---|---|---|---|---|---|---|---|---|")
|
|
247
|
+
prep = sorted(spec.get("data_prep", []), key=lambda d: d["target_screen"] != "共通") # 共通 first, stable
|
|
248
|
+
for i, d in enumerate(prep, 1):
|
|
249
|
+
cells = [bi_cell(bi(d[k]), bi(d[k], "vi")) for k in ("category", "target", "state", "count", "method")]
|
|
250
|
+
w(f"| {i} | {md_cell(d['target_screen'])} | " + " | ".join(cells) + " | | |")
|
|
251
|
+
w("")
|
|
252
|
+
|
|
253
|
+
# ---- 画面別シート
|
|
254
|
+
vp = spec.get("viewpoints", {})
|
|
255
|
+
layers = [f"platform:{p}" for p in vp.get("platforms", [])]
|
|
256
|
+
if vp.get("customer"):
|
|
257
|
+
tags = "/".join(vp.get("customer_tags", []))
|
|
258
|
+
layers.insert(0, f"customer:{vp['customer']}" + (f"({tags})" if tags else ""))
|
|
259
|
+
vp_layers = "、".join(layers)
|
|
260
|
+
for sh in spec["sheets"]:
|
|
261
|
+
w(f"## {sh['name']}")
|
|
262
|
+
w("")
|
|
263
|
+
w(f"- 中分類(画面名) / Tên màn hình: **{sh['screen_name']}** / {sh.get('screen_name_vi', '')}")
|
|
264
|
+
w(f"- 参照観点(画面種別) / Quan điểm test tham chiếu (loại màn hình): `{'、'.join(sh['screen_types'])}`"
|
|
265
|
+
+ (f" + {vp_layers}" if vp_layers else ""))
|
|
266
|
+
if sh.get("note"):
|
|
267
|
+
w(f"- 備考 / Ghi chú: {bi_cell(bi(sh['note']), bi(sh['note'], 'vi'))}")
|
|
268
|
+
w("")
|
|
269
|
+
w("| No | 大分類<br>Phân loại lớn | 中分類(画面名)<br>Phân loại trung (màn hình) | 小分類<br>Phân loại nhỏ"
|
|
270
|
+
" | 関連仕様書ID・画面ID<br>ID đặc tả・màn hình | 操作手順<br>Thao tác | 期待結果(画面)<br>Kết quả mong đợi (màn hình)"
|
|
271
|
+
" | 期待結果(DB)<br>Kết quả mong đợi (DB) | 実施日<br>Ngày test | 実施者<br>Người test | 結果<br>Kết quả"
|
|
272
|
+
" | 不具合チケットNo<br>Ticket lỗi | 備考<br>Ghi chú |")
|
|
273
|
+
w("|---|---|---|---|---|---|---|---|---|---|---|---|---|")
|
|
274
|
+
for no, c in enumerate(sorted_cases(sh, majors), 1):
|
|
275
|
+
db_ja, db_vi = c["db"]["ja"], c["db"]["vi"]
|
|
276
|
+
if db_ja.strip() == NO_DB and db_vi.strip() in ("", NO_DB):
|
|
277
|
+
db_vi = NO_DB_VI
|
|
278
|
+
cells = [
|
|
279
|
+
str(no),
|
|
280
|
+
f"{c['major']}<br>{major_vi[c['major']]}",
|
|
281
|
+
f"{md_cell(sh['screen_name'])}<br>{md_cell(sh.get('screen_name_vi', ''))}",
|
|
282
|
+
f"{c['minor']}<br>{minor_vi[c['minor']]}",
|
|
283
|
+
md_cell(c["spec"]),
|
|
284
|
+
steps_cell(c["steps"]),
|
|
285
|
+
bi_cell(c["screen"]["ja"], c["screen"]["vi"]),
|
|
286
|
+
bi_cell(db_ja, db_vi),
|
|
287
|
+
"", "", "", "", "",
|
|
288
|
+
]
|
|
289
|
+
w("| " + " | ".join(cells) + " |")
|
|
290
|
+
w("")
|
|
291
|
+
|
|
292
|
+
# ---- 報告 (§11)
|
|
293
|
+
if spec.get("report"):
|
|
294
|
+
w("## 作成報告 / Báo cáo khi tạo")
|
|
295
|
+
w("")
|
|
296
|
+
w("> `テスト仕様書作成ルール.md` §11 の報告項目。人がチェックする際の最重要情報。 ")
|
|
297
|
+
w("> Các mục báo cáo theo §11 của `テスト仕様書作成ルール.md` — thông tin quan trọng nhất khi review.")
|
|
298
|
+
w("")
|
|
299
|
+
for sec in spec["report"]:
|
|
300
|
+
w(f"### {sec['title_ja']} / {sec['title_vi']}")
|
|
301
|
+
w("")
|
|
302
|
+
if not sec.get("items"):
|
|
303
|
+
w("- なし / Không có")
|
|
304
|
+
for it in sec.get("items", []):
|
|
305
|
+
w(f"- {md_cell(it['ja'])}")
|
|
306
|
+
if it.get("vi"):
|
|
307
|
+
w(f" - 🇻🇳 {md_cell(it['vi'])}")
|
|
308
|
+
w("")
|
|
309
|
+
return "\n".join(out)
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
def setup_sheet(ws, majors):
|
|
313
|
+
"""§8 of テスト仕様書作成ルール.md — restore what copy_worksheet() drops."""
|
|
314
|
+
from openpyxl.worksheet.datavalidation import DataValidation
|
|
315
|
+
from openpyxl.worksheet.page import PageMargins
|
|
316
|
+
|
|
317
|
+
ws.freeze_panes = "B2"
|
|
318
|
+
ws.auto_filter.ref = "A1:M501"
|
|
319
|
+
ws.print_title_rows = "1:1"
|
|
320
|
+
ws.oddHeader.left.text = "&A"
|
|
321
|
+
ws.oddHeader.left.size = 9
|
|
322
|
+
ws.oddFooter.center.text = "&P / &N"
|
|
323
|
+
ws.oddFooter.center.size = 9
|
|
324
|
+
ws.page_margins = PageMargins(left=0.4, right=0.4, top=0.6, bottom=0.5, header=0.3, footer=0.3)
|
|
325
|
+
for rng, items, strict in [
|
|
326
|
+
("B2:B501", ",".join(m[0] for m in majors), False), # §8 list + extra_majors in band order
|
|
327
|
+
("D2:D501", "正常系,異常系,境界値", True),
|
|
328
|
+
("K2:K501", "OK,NG,保留,対象外,未実施", True),
|
|
329
|
+
]:
|
|
330
|
+
dv = DataValidation(type="list", formula1=f'"{items}"', allow_blank=True, showErrorMessage=strict)
|
|
331
|
+
ws.add_data_validation(dv)
|
|
332
|
+
dv.add(rng)
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
def render_xlsx(spec, path):
|
|
336
|
+
"""Optional: fill the real template. Text is bilingual (JA line(s), then 🇻🇳 VI line(s)) in each cell."""
|
|
337
|
+
from openpyxl import load_workbook
|
|
338
|
+
from openpyxl.styles import Alignment, Font
|
|
339
|
+
|
|
340
|
+
font = Font(name="Meiryo UI", size=9, italic=False, color="FF000000")
|
|
341
|
+
align = Alignment(wrap_text=True, vertical="top")
|
|
342
|
+
|
|
343
|
+
def put(ws, ref, value):
|
|
344
|
+
ws[ref] = value
|
|
345
|
+
ws[ref].font = font
|
|
346
|
+
ws[ref].alignment = align
|
|
347
|
+
|
|
348
|
+
def bitext(v):
|
|
349
|
+
ja, vi = bi(v), bi(v, "vi")
|
|
350
|
+
return f"{ja}\n🇻🇳 {vi}" if vi else ja
|
|
351
|
+
|
|
352
|
+
majors = band_table(spec.get("extra_majors", []))
|
|
353
|
+
wb = load_workbook(TEMPLATE)
|
|
354
|
+
cov = wb["表紙"]
|
|
355
|
+
for ref, key in (("B3", "system_name"), ("B4", "subsystem_name"), ("B5", "function_name"), ("B6", "related_specs")):
|
|
356
|
+
cov[ref] = bitext(spec["cover"][key])
|
|
357
|
+
for i, sh in enumerate(spec["sheets"]):
|
|
358
|
+
cov[f"A{21 + i}"] = sh["name"]
|
|
359
|
+
prep_ws = wb["テストデータ準備"]
|
|
360
|
+
prep = sorted(spec.get("data_prep", []), key=lambda d: d["target_screen"] != "共通")
|
|
361
|
+
for i, d in enumerate(prep):
|
|
362
|
+
r = 2 + i
|
|
363
|
+
put(prep_ws, f"A{r}", i + 1)
|
|
364
|
+
put(prep_ws, f"B{r}", d["target_screen"])
|
|
365
|
+
for col, k in zip("CDEFG", ("category", "target", "state", "count", "method")):
|
|
366
|
+
put(prep_ws, f"{col}{r}", bitext(d[k]))
|
|
367
|
+
for sh in spec["sheets"]:
|
|
368
|
+
ws = wb.copy_worksheet(wb["00_雛型"])
|
|
369
|
+
ws.title = sh["name"]
|
|
370
|
+
setup_sheet(ws, majors)
|
|
371
|
+
for no, c in enumerate(sorted_cases(sh, majors), 1):
|
|
372
|
+
r = 1 + no
|
|
373
|
+
steps = "\n".join(f"{i}. {s}" for i, s in enumerate(c["steps"]["ja"], 1)) + "\n🇻🇳\n" + \
|
|
374
|
+
"\n".join(f"{i}. {s}" for i, s in enumerate(c["steps"]["vi"], 1))
|
|
375
|
+
for col, val in zip("ABCDEFGH", (no, c["major"], sh["screen_name"], c["minor"], c["spec"], steps,
|
|
376
|
+
bitext(c["screen"]), bitext(c["db"]))):
|
|
377
|
+
put(ws, f"{col}{r}", val)
|
|
378
|
+
wb.save(path)
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
def main():
|
|
382
|
+
ap = argparse.ArgumentParser()
|
|
383
|
+
ap.add_argument("spec")
|
|
384
|
+
ap.add_argument("--md")
|
|
385
|
+
ap.add_argument("--xlsx")
|
|
386
|
+
ap.add_argument("--check-only", action="store_true")
|
|
387
|
+
ap.add_argument("--template-dir", help="template set folder (default: spec template_set, else ja-default)")
|
|
388
|
+
a = ap.parse_args()
|
|
389
|
+
with open(a.spec, encoding="utf-8") as f:
|
|
390
|
+
spec = json.load(f)
|
|
391
|
+
global TEMPLATE
|
|
392
|
+
TEMPLATE = template_set.output_template(template_set.resolve(a.template_dir or spec.get("template_set")))
|
|
393
|
+
errors, warnings = validate(spec)
|
|
394
|
+
for m in warnings + errors:
|
|
395
|
+
print(m)
|
|
396
|
+
majors = band_table(spec.get("extra_majors", []))
|
|
397
|
+
for sh in spec["sheets"]:
|
|
398
|
+
by = {}
|
|
399
|
+
for c in sh["cases"]:
|
|
400
|
+
by.setdefault(c.get("major"), {}).setdefault(c.get("minor"), 0)
|
|
401
|
+
by[c.get("major")][c.get("minor")] += 1
|
|
402
|
+
print(f"{sh['name']}: {len(sh['cases'])} cases")
|
|
403
|
+
for mj, _ in majors:
|
|
404
|
+
if mj in by:
|
|
405
|
+
print(f" {mj}: " + ", ".join(f"{k}={v}" for k, v in by[mj].items()))
|
|
406
|
+
print(f"data_prep: {len(spec.get('data_prep', []))} items")
|
|
407
|
+
if errors:
|
|
408
|
+
sys.exit(f"{len(errors)} error(s) — fix the JSON and re-run")
|
|
409
|
+
if a.check_only:
|
|
410
|
+
return
|
|
411
|
+
if a.md:
|
|
412
|
+
with open(a.md, "w", encoding="utf-8") as f:
|
|
413
|
+
f.write(render_md(spec) + "\n")
|
|
414
|
+
print(f"wrote {a.md}")
|
|
415
|
+
if a.xlsx:
|
|
416
|
+
render_xlsx(spec, a.xlsx)
|
|
417
|
+
print(f"wrote {a.xlsx}")
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
if __name__ == "__main__":
|
|
421
|
+
main()
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""Finds the template set (output template, writing rules, viewpoints) a test specification is built with.
|
|
3
|
+
|
|
4
|
+
A template set is a folder with a TEMPLATE.md manifest. Resolution order — the first that exists wins:
|
|
5
|
+
1. an explicit folder (base.json "template_set" when it is a path, or --template-dir)
|
|
6
|
+
2. <project root>/docs/templates/test-case-xlsx/<set name> (a customer's own set, kept in the project)
|
|
7
|
+
3. <toolkit>/templates/test-case-xlsx/<set name> (shipped sets; <toolkit> = two levels above skills/)
|
|
8
|
+
or <skill>/references/templates/test-case-xlsx/<set name> (the same sets copied into an installed Claude skill)
|
|
9
|
+
4. $SDTK_TEMPLATES_DIR/test-case-xlsx/<set name>
|
|
10
|
+
The set name defaults to "ja-default". TEMPLATE.md may carry a ```json config``` block read by config().
|
|
11
|
+
"""
|
|
12
|
+
import json
|
|
13
|
+
import os
|
|
14
|
+
import re
|
|
15
|
+
|
|
16
|
+
KIND = "test-case-xlsx"
|
|
17
|
+
DEFAULT_SET = "ja-default"
|
|
18
|
+
SKILL_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class TemplateSetError(RuntimeError):
|
|
22
|
+
pass
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def candidates(name_or_path=None, project_root=None):
|
|
26
|
+
value = name_or_path or DEFAULT_SET
|
|
27
|
+
if os.path.isabs(value) or os.sep in value or "/" in value:
|
|
28
|
+
base = project_root or os.getcwd()
|
|
29
|
+
return [value if os.path.isabs(value) else os.path.join(base, value)]
|
|
30
|
+
out = [os.path.join(project_root or os.getcwd(), "docs", "templates", KIND, value),
|
|
31
|
+
os.path.join(SKILL_DIR, "..", "..", "templates", KIND, value), # toolkit layout
|
|
32
|
+
os.path.join(SKILL_DIR, "references", "templates", KIND, value)] # installed Claude skill layout
|
|
33
|
+
if os.environ.get("SDTK_TEMPLATES_DIR"):
|
|
34
|
+
out.append(os.path.join(os.environ["SDTK_TEMPLATES_DIR"], KIND, value))
|
|
35
|
+
return [os.path.normpath(p) for p in out]
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def resolve(name_or_path=None, project_root=None) -> str:
|
|
39
|
+
tried = candidates(name_or_path, project_root)
|
|
40
|
+
for path in tried:
|
|
41
|
+
if os.path.isfile(os.path.join(path, "TEMPLATE.md")):
|
|
42
|
+
return path
|
|
43
|
+
raise TemplateSetError("no template set with a TEMPLATE.md at: " + "; ".join(tried))
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def config(set_dir) -> dict:
|
|
47
|
+
with open(os.path.join(set_dir, "TEMPLATE.md"), encoding="utf-8") as f:
|
|
48
|
+
m = re.search(r"```json config\s*\n(.*?)```", f.read(), re.S)
|
|
49
|
+
return json.loads(m.group(1)) if m else {}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def output_template(set_dir) -> str:
|
|
53
|
+
return os.path.join(set_dir, config(set_dir).get("output_template", "テスト仕様書雛型.xlsx"))
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def viewpoints_dir(set_dir) -> str:
|
|
57
|
+
return os.path.join(set_dir, config(set_dir).get("viewpoints_dir", "viewpoints"))
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""template_set + write_results — python -m unittest test_write_results (from this folder)."""
|
|
3
|
+
import os
|
|
4
|
+
import sys
|
|
5
|
+
import tempfile
|
|
6
|
+
import unittest
|
|
7
|
+
import zipfile
|
|
8
|
+
|
|
9
|
+
HERE = os.path.dirname(os.path.abspath(__file__))
|
|
10
|
+
sys.path.insert(0, HERE)
|
|
11
|
+
import template_set # noqa: E402
|
|
12
|
+
import write_results # noqa: E402
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def fixture(path):
|
|
16
|
+
"""A spec workbook: a cover sheet with a picture, and a case sheet (No in A, results in I/J/K/M)."""
|
|
17
|
+
import openpyxl
|
|
18
|
+
from openpyxl.drawing.image import Image as XlImage
|
|
19
|
+
from PIL import Image
|
|
20
|
+
png = path + ".png"
|
|
21
|
+
Image.new("RGB", (40, 20), "red").save(png)
|
|
22
|
+
wb = openpyxl.Workbook()
|
|
23
|
+
cover = wb.active
|
|
24
|
+
cover.title = "Cover"
|
|
25
|
+
cover.add_image(XlImage(png), "B2")
|
|
26
|
+
ws = wb.create_sheet("01_Screen")
|
|
27
|
+
ws.append(["No", "b", "c", "d", "e", "f", "g", "h", "Date", "Tester", "Result", "l", "Note"])
|
|
28
|
+
for n in (1, 2, 3):
|
|
29
|
+
ws.append([n] + [""] * 12)
|
|
30
|
+
wb.save(path) # a fresh fixture written by the test itself
|
|
31
|
+
return path
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class TemplateSet(unittest.TestCase):
|
|
35
|
+
def test_default_set_is_found_with_its_config(self):
|
|
36
|
+
set_dir = template_set.resolve(project_root=tempfile.gettempdir())
|
|
37
|
+
self.assertTrue(set_dir.endswith(os.path.join("test-case-xlsx", "ja-default")))
|
|
38
|
+
self.assertEqual(template_set.config(set_dir)["results"]["columns"]["result"], "K")
|
|
39
|
+
self.assertTrue(os.path.exists(template_set.output_template(set_dir)))
|
|
40
|
+
|
|
41
|
+
def test_project_set_wins(self):
|
|
42
|
+
with tempfile.TemporaryDirectory() as root:
|
|
43
|
+
own = os.path.join(root, "docs", "templates", "test-case-xlsx", "acme")
|
|
44
|
+
os.makedirs(own)
|
|
45
|
+
open(os.path.join(own, "TEMPLATE.md"), "w").write("# acme\n")
|
|
46
|
+
self.assertEqual(template_set.resolve("acme", project_root=root), os.path.normpath(own))
|
|
47
|
+
|
|
48
|
+
def test_missing_set_names_where_it_looked(self):
|
|
49
|
+
with self.assertRaisesRegex(template_set.TemplateSetError, "no template set"):
|
|
50
|
+
template_set.resolve("nope", project_root=tempfile.gettempdir())
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class WriteResults(unittest.TestCase):
|
|
54
|
+
def setUp(self):
|
|
55
|
+
self.tmp = tempfile.TemporaryDirectory()
|
|
56
|
+
self.book = fixture(os.path.join(self.tmp.name, "spec.xlsx"))
|
|
57
|
+
self.set_dir = template_set.resolve(project_root=self.tmp.name)
|
|
58
|
+
|
|
59
|
+
def tearDown(self):
|
|
60
|
+
self.tmp.cleanup()
|
|
61
|
+
|
|
62
|
+
def test_writes_only_the_case_sheet(self):
|
|
63
|
+
before = zipfile.ZipFile(self.book)
|
|
64
|
+
media_before = {n: before.read(n) for n in before.namelist() if n.startswith("xl/media/")}
|
|
65
|
+
before.close()
|
|
66
|
+
results = {"tester": "QA", "date": "2026-11-21",
|
|
67
|
+
"cases": {"2": {"result": "NG", "note": "button missing", "shots": ["2.png", "2.png"]}}}
|
|
68
|
+
self.assertEqual(write_results.write(self.book, "01_Screen", results, self.set_dir, self.tmp.name), ["2"])
|
|
69
|
+
import openpyxl
|
|
70
|
+
ws = openpyxl.load_workbook(self.book)["01_Screen"]
|
|
71
|
+
self.assertEqual((ws["I3"].value, ws["J3"].value, ws["K3"].value), ("2026/11/21", "QA", "NG"))
|
|
72
|
+
self.assertEqual(ws["M3"].value, "エビデンス: 2.png\nbutton missing")
|
|
73
|
+
self.assertIsNone(ws["K2"].value)
|
|
74
|
+
after = zipfile.ZipFile(self.book)
|
|
75
|
+
self.assertEqual({n: after.read(n) for n in after.namelist() if n.startswith("xl/media/")}, media_before)
|
|
76
|
+
|
|
77
|
+
def test_refuses_unsettled_and_unknown_cases(self):
|
|
78
|
+
for cases in ({"1": {"result": "要目視"}}, {"9": {"result": "OK"}}):
|
|
79
|
+
with self.assertRaises(write_results.ResultsError):
|
|
80
|
+
write_results.write(self.book, "01_Screen", {"date": "2026-11-21", "cases": cases}, self.set_dir)
|
|
81
|
+
|
|
82
|
+
def test_refuses_while_open_in_excel(self):
|
|
83
|
+
open(os.path.join(self.tmp.name, "~$spec.xlsx"), "w").close()
|
|
84
|
+
with self.assertRaisesRegex(write_results.ResultsError, "open in Excel"):
|
|
85
|
+
write_results.write(self.book, "01_Screen", {"date": "2026-11-21", "cases": {}}, self.set_dir)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
if __name__ == "__main__":
|
|
89
|
+
unittest.main()
|