mtkit 1.16.1__py3-none-any.whl
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.
- mtkit/__init__.py +36 -0
- mtkit/__main__.py +6 -0
- mtkit/asset.py +101 -0
- mtkit/audit.py +220 -0
- mtkit/builder.py +100 -0
- mtkit/cli.py +885 -0
- mtkit/conf.py +63 -0
- mtkit/coverage.py +175 -0
- mtkit/db.py +676 -0
- mtkit/evolve.py +142 -0
- mtkit/extract/__init__.py +17 -0
- mtkit/extract/code_facts.py +631 -0
- mtkit/extract/docx_loader.py +115 -0
- mtkit/extract/xmind_loader.py +125 -0
- mtkit/generate/__init__.py +10 -0
- mtkit/generate/llm.py +360 -0
- mtkit/generate/prompts.py +178 -0
- mtkit/generate/skeleton.py +59 -0
- mtkit/normalize.py +480 -0
- mtkit/parsers.py +318 -0
- mtkit/review.py +274 -0
- mtkit/selfheal.py +110 -0
- mtkit/tb.py +191 -0
- mtkit/track.py +309 -0
- mtkit/validator.py +174 -0
- mtkit/writer.py +137 -0
- mtkit-1.16.1.dist-info/METADATA +150 -0
- mtkit-1.16.1.dist-info/RECORD +31 -0
- mtkit-1.16.1.dist-info/WHEEL +5 -0
- mtkit-1.16.1.dist-info/entry_points.txt +2 -0
- mtkit-1.16.1.dist-info/top_level.txt +1 -0
mtkit/validator.py
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
Validation module: quality checks for the case tree structure and generated XMind files
|
|
4
|
+
|
|
5
|
+
supports two case description styles:
|
|
6
|
+
- zen style: case children are pc:/步骤:/预期: flat description lines (default)
|
|
7
|
+
- history style: case children are 「操作步骤」「预期结果」 multi-level nodes (legacy iteration case format)
|
|
8
|
+
|
|
9
|
+
optional strict rule require_sql: DB-interaction cases must contain SQL check content.
|
|
10
|
+
"""
|
|
11
|
+
import json
|
|
12
|
+
import os
|
|
13
|
+
import zipfile
|
|
14
|
+
|
|
15
|
+
from .builder import CASE_PREFIX, REQUIRED_SECTION_PREFIXES
|
|
16
|
+
from .normalize import (
|
|
17
|
+
HISTORY_EXPECT_TITLES,
|
|
18
|
+
HISTORY_PC_TITLES,
|
|
19
|
+
HISTORY_STEP_TITLES,
|
|
20
|
+
case_has_sql,
|
|
21
|
+
case_needs_sql,
|
|
22
|
+
detect_style,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def check_tree(nodes, errors=None, style="zen", require_sql=False, require_pc=False):
|
|
27
|
+
"""Validate the case tree structure, return a list of error messages.
|
|
28
|
+
|
|
29
|
+
rules:
|
|
30
|
+
1. every node must have a non-empty title t
|
|
31
|
+
2. case nodes (title starting with tc-) must contain pc:/步骤:/预期: description lines (zen style)
|
|
32
|
+
or 「操作步骤」「预期结果」 child nodes (history style)
|
|
33
|
+
3. when require_sql is on, DB-interaction cases must contain SQL check content
|
|
34
|
+
4. when require_pc is on, history style cases must contain a 「前置条件」 node (content may be "无")
|
|
35
|
+
|
|
36
|
+
:param nodes: case tree [{t=..., c=[...]}, ...]
|
|
37
|
+
:param errors: externally passed error list, created by default
|
|
38
|
+
:param style: case description style "zen" / "history" / "auto" (auto detect)
|
|
39
|
+
:param require_sql: force DB-interaction cases to contain SQL checks
|
|
40
|
+
:param require_pc: force cases to contain preconditions
|
|
41
|
+
:return: error message list, empty list means pass
|
|
42
|
+
"""
|
|
43
|
+
if style == "auto":
|
|
44
|
+
style = detect_style(nodes)
|
|
45
|
+
if style == "mixed":
|
|
46
|
+
style = "zen" # 混合风格按 zen 校验(容错)
|
|
47
|
+
|
|
48
|
+
errors = errors if errors is not None else []
|
|
49
|
+
for node in nodes:
|
|
50
|
+
title = node.get("t")
|
|
51
|
+
if not title:
|
|
52
|
+
errors.append("存在空标题节点")
|
|
53
|
+
continue
|
|
54
|
+
if title.startswith(CASE_PREFIX):
|
|
55
|
+
subs = [c.get("t") for c in node.get("c") or []]
|
|
56
|
+
if style == "history":
|
|
57
|
+
_check_history_case(node, subs, require_sql, require_pc, errors)
|
|
58
|
+
else:
|
|
59
|
+
_check_zen_case(node, subs, require_sql, errors)
|
|
60
|
+
else:
|
|
61
|
+
check_tree(node.get("c") or [], errors, style, require_sql, require_pc)
|
|
62
|
+
return errors
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def _check_zen_case(node, subs, require_sql, errors):
|
|
66
|
+
"""zen style case node validation: must have pc:/步骤:/预期: description lines."""
|
|
67
|
+
for prefix in REQUIRED_SECTION_PREFIXES:
|
|
68
|
+
if not any(s.startswith(prefix) for s in subs):
|
|
69
|
+
errors.append("用例缺少 %s 描述: %s" % (prefix, node["t"]))
|
|
70
|
+
_check_require_sql(node, require_sql, errors)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def _check_history_case(node, subs, require_sql, require_pc, errors):
|
|
74
|
+
"""history style case node validation: must have 「操作步骤」 and 「预期结果」 child nodes."""
|
|
75
|
+
if not any(s in HISTORY_STEP_TITLES for s in subs):
|
|
76
|
+
errors.append("用例缺少「操作步骤」节点: %s" % node["t"])
|
|
77
|
+
if not any(s in HISTORY_EXPECT_TITLES for s in subs):
|
|
78
|
+
errors.append("用例缺少「预期结果」节点: %s" % node["t"])
|
|
79
|
+
if require_pc and not any(
|
|
80
|
+
s.startswith(("pc:", "pc:")) or s in HISTORY_PC_TITLES for s in subs
|
|
81
|
+
):
|
|
82
|
+
errors.append("用例缺少「pc:」前置条件: %s" % node["t"])
|
|
83
|
+
_check_require_sql(node, require_sql, errors)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def _check_require_sql(node, require_sql, errors):
|
|
87
|
+
"""require_sql rule: DB-interaction cases must contain SQL check content."""
|
|
88
|
+
if not require_sql:
|
|
89
|
+
return
|
|
90
|
+
if case_needs_sql(node) and not case_has_sql(node):
|
|
91
|
+
errors.append("数据库交互用例缺少 SQL 核对内容: %s" % node["t"])
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def collect_ids(root_topic):
|
|
95
|
+
"""Collect all node IDs under rootTopic (including the root)"""
|
|
96
|
+
ids = []
|
|
97
|
+
|
|
98
|
+
def walk(topic):
|
|
99
|
+
ids.append(topic["id"])
|
|
100
|
+
for child in (topic.get("children") or {}).get("attached") or []:
|
|
101
|
+
walk(child)
|
|
102
|
+
|
|
103
|
+
walk(root_topic)
|
|
104
|
+
return ids
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def check_sheet(sheet, errors=None):
|
|
108
|
+
"""Validate a built sheet structure, return a list of error messages.
|
|
109
|
+
|
|
110
|
+
rules:
|
|
111
|
+
1. node IDs globally unique
|
|
112
|
+
2. rootTopic exists and has a non-empty title
|
|
113
|
+
3. case structure complete (calls check_tree)
|
|
114
|
+
|
|
115
|
+
:param sheet: sheet dict returned by build_sheet
|
|
116
|
+
:param errors: externally passed error list, created by default
|
|
117
|
+
:return: error message list, empty list means pass
|
|
118
|
+
"""
|
|
119
|
+
errors = errors if errors is not None else []
|
|
120
|
+
root = sheet.get("rootTopic") or {}
|
|
121
|
+
if not root.get("title"):
|
|
122
|
+
errors.append("根节点标题为空")
|
|
123
|
+
ids = collect_ids(root)
|
|
124
|
+
if len(ids) != len(set(ids)):
|
|
125
|
+
errors.append("节点 ID 重复: 总数 %d, 唯一 %d" % (len(ids), len(set(ids))))
|
|
126
|
+
return errors
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def check_xmind_file(path, errors=None):
|
|
130
|
+
"""校验 .xmind 文件:zip 可打开、content.json/content.xml 可解析、结构完整。
|
|
131
|
+
|
|
132
|
+
:param path: .xmind 文件路径
|
|
133
|
+
:param errors: 外部传入的错误列表,缺省新建
|
|
134
|
+
:return: 错误信息列表,空列表表示通过
|
|
135
|
+
"""
|
|
136
|
+
errors = errors if errors is not None else []
|
|
137
|
+
if not os.path.isfile(path):
|
|
138
|
+
errors.append("文件不存在: %s" % path)
|
|
139
|
+
return errors
|
|
140
|
+
try:
|
|
141
|
+
with zipfile.ZipFile(path) as zf:
|
|
142
|
+
names = zf.namelist()
|
|
143
|
+
if "content.json" in names:
|
|
144
|
+
data = json.loads(zf.read("content.json").decode("utf-8"))
|
|
145
|
+
elif "content.xml" in names:
|
|
146
|
+
data = _parse_xmind8_for_check(zf.read("content.xml").decode("utf-8"))
|
|
147
|
+
else:
|
|
148
|
+
errors.append("缺少 content.json/content.xml")
|
|
149
|
+
return errors
|
|
150
|
+
except zipfile.BadZipFile:
|
|
151
|
+
errors.append("不是有效的 zip/xmind 文件: %s" % path)
|
|
152
|
+
return errors
|
|
153
|
+
except json.JSONDecodeError as exc:
|
|
154
|
+
errors.append("content.json 解析失败: %s" % exc)
|
|
155
|
+
return errors
|
|
156
|
+
except Exception as exc:
|
|
157
|
+
errors.append("content.xml 解析失败: %s" % exc)
|
|
158
|
+
return errors
|
|
159
|
+
if not isinstance(data, list) or not data:
|
|
160
|
+
errors.append("content 结构异常: 应为非空数组")
|
|
161
|
+
return errors
|
|
162
|
+
for index, sheet in enumerate(data):
|
|
163
|
+
sheet_errors = []
|
|
164
|
+
check_sheet(sheet, sheet_errors)
|
|
165
|
+
for msg in sheet_errors:
|
|
166
|
+
errors.append("sheet[%d] %s" % (index, msg))
|
|
167
|
+
return errors
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def _parse_xmind8_for_check(xml_text):
|
|
171
|
+
"""XMind 8 content.xml 转 Zen sheet 数组(复用 writer 的解析)。"""
|
|
172
|
+
from .writer import _parse_xmind8_sheets
|
|
173
|
+
|
|
174
|
+
return _parse_xmind8_sheets(xml_text)
|
mtkit/writer.py
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
Write/read module: .xmind file (zip) packaging and parsing
|
|
4
|
+
|
|
5
|
+
reading auto-detects two formats:
|
|
6
|
+
- Zen format (content.json, new XMind)
|
|
7
|
+
- XMind 8 format (content.xml, old XMind, converted to the Zen structure on read)
|
|
8
|
+
writing outputs the Zen format.
|
|
9
|
+
"""
|
|
10
|
+
import json
|
|
11
|
+
import zipfile
|
|
12
|
+
import xml.etree.ElementTree as ET
|
|
13
|
+
|
|
14
|
+
CONTENT_NAME = "content.json"
|
|
15
|
+
METADATA_NAME = "metadata.json"
|
|
16
|
+
MANIFEST_NAME = "manifest.json"
|
|
17
|
+
XCONTENT_NAME = "content.xml"
|
|
18
|
+
|
|
19
|
+
# XMind 8 content.xml namespace
|
|
20
|
+
_XMIND8_NS = "urn:xmind:xmap:xmlns:content:2.0"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def _dumps(obj):
|
|
24
|
+
return json.dumps(obj, ensure_ascii=False, indent=2)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def write_xmind(path, sheet, metadata=None, manifest=None):
|
|
28
|
+
"""Package the sheet structure and write it into a .xmind file.
|
|
29
|
+
|
|
30
|
+
:param path: output file path (recommended to end with .xmind)
|
|
31
|
+
:param sheet: sheet dict returned by build_sheet (or the sheet structure itself)
|
|
32
|
+
:param metadata: metadata.json content, defaults to builder built-ins
|
|
33
|
+
:param manifest: manifest.json content, defaults to builder built-ins
|
|
34
|
+
"""
|
|
35
|
+
if isinstance(sheet, dict) and "sheet" in sheet and "metadata" in sheet:
|
|
36
|
+
payload = sheet
|
|
37
|
+
else:
|
|
38
|
+
from .builder import DEFAULT_MANIFEST, DEFAULT_METADATA
|
|
39
|
+
|
|
40
|
+
payload = {
|
|
41
|
+
"sheet": sheet,
|
|
42
|
+
"metadata": metadata or DEFAULT_METADATA,
|
|
43
|
+
"manifest": manifest or DEFAULT_MANIFEST,
|
|
44
|
+
}
|
|
45
|
+
with zipfile.ZipFile(path, "w", zipfile.ZIP_DEFLATED) as zf:
|
|
46
|
+
zf.writestr(CONTENT_NAME, _dumps([payload["sheet"]]))
|
|
47
|
+
zf.writestr(METADATA_NAME, _dumps(payload["metadata"]))
|
|
48
|
+
zf.writestr(MANIFEST_NAME, _dumps(payload["manifest"]))
|
|
49
|
+
return path
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def read_xmind(path):
|
|
53
|
+
"""Read a .xmind file, return the sheet array (auto-detect Zen/XMind 8 format).
|
|
54
|
+
|
|
55
|
+
:param path: .xmind file path
|
|
56
|
+
:return: sheet array ([{rootTopic: ...}, ...])
|
|
57
|
+
"""
|
|
58
|
+
with zipfile.ZipFile(path) as zf:
|
|
59
|
+
names = zf.namelist()
|
|
60
|
+
if CONTENT_NAME in names:
|
|
61
|
+
return json.loads(zf.read(CONTENT_NAME).decode("utf-8"))
|
|
62
|
+
if XCONTENT_NAME in names:
|
|
63
|
+
return _parse_xmind8_sheets(zf.read(XCONTENT_NAME).decode("utf-8"))
|
|
64
|
+
raise ValueError("不支持的 xmind 格式(缺少 %s/%s): %s" % (CONTENT_NAME, XCONTENT_NAME, path))
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def _parse_xmind8_sheets(xml_text):
|
|
68
|
+
"""XMind 8 content.xml -> Zen sheet array.
|
|
69
|
+
|
|
70
|
+
:param xml_text: content.xml text
|
|
71
|
+
:return: [{rootTopic: ...}, ...]
|
|
72
|
+
"""
|
|
73
|
+
root = ET.fromstring(xml_text)
|
|
74
|
+
sheets = []
|
|
75
|
+
for sheet in root.findall("{%s}sheet" % _XMIND8_NS):
|
|
76
|
+
topic = sheet.find("{%s}topic" % _XMIND8_NS)
|
|
77
|
+
if topic is None:
|
|
78
|
+
continue
|
|
79
|
+
sheets.append({"rootTopic": _xmind8_topic_to_zen(topic)})
|
|
80
|
+
return sheets
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def _xmind8_topic_to_zen(topic):
|
|
84
|
+
"""XMind 8 topic element -> Zen topic dict."""
|
|
85
|
+
title_el = topic.find("{%s}title" % _XMIND8_NS)
|
|
86
|
+
title = (title_el.text or "").strip() if title_el is not None else ""
|
|
87
|
+
node = {
|
|
88
|
+
"id": topic.get("id") or "",
|
|
89
|
+
"title": title,
|
|
90
|
+
}
|
|
91
|
+
children_el = topic.find("{%s}children" % _XMIND8_NS)
|
|
92
|
+
attached = []
|
|
93
|
+
if children_el is not None:
|
|
94
|
+
for topics_el in children_el.findall("{%s}topics" % _XMIND8_NS):
|
|
95
|
+
for child in topics_el.findall("{%s}topic" % _XMIND8_NS):
|
|
96
|
+
attached.append(_xmind8_topic_to_zen(child))
|
|
97
|
+
if attached:
|
|
98
|
+
node["children"] = {"attached": attached}
|
|
99
|
+
return node
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def read_tree(path):
|
|
103
|
+
"""读取 .xmind 文件,还原为用例树结构 [{t=..., c=[...]}, ...]。
|
|
104
|
+
|
|
105
|
+
与生成时的数据约定互逆:topic -> {t: title, c: [子节点]},根节点不包含。
|
|
106
|
+
容错:真实 xmind 中图片/标记节点无 title,跳过无文本信息的纯资源节点。
|
|
107
|
+
|
|
108
|
+
:param path: .xmind 文件路径
|
|
109
|
+
:return: 用例树(根节点的子节点列表)
|
|
110
|
+
"""
|
|
111
|
+
sheets = read_xmind(path)
|
|
112
|
+
if not sheets:
|
|
113
|
+
return []
|
|
114
|
+
|
|
115
|
+
def topic_to_node(topic):
|
|
116
|
+
title = topic.get("title") or ""
|
|
117
|
+
children = (topic.get("children") or {}).get("attached") or []
|
|
118
|
+
valid_children = []
|
|
119
|
+
for child in children:
|
|
120
|
+
node = topic_to_node(child)
|
|
121
|
+
if node is not None:
|
|
122
|
+
valid_children.append(node)
|
|
123
|
+
# no title and no valid children: pure image/marker node, skip
|
|
124
|
+
if not title and not valid_children:
|
|
125
|
+
return None
|
|
126
|
+
node = {"t": title}
|
|
127
|
+
if valid_children:
|
|
128
|
+
node["c"] = valid_children
|
|
129
|
+
return node
|
|
130
|
+
|
|
131
|
+
root = sheets[0].get("rootTopic") or {}
|
|
132
|
+
nodes = []
|
|
133
|
+
for child in (root.get("children") or {}).get("attached") or []:
|
|
134
|
+
node = topic_to_node(child)
|
|
135
|
+
if node is not None:
|
|
136
|
+
nodes.append(node)
|
|
137
|
+
return nodes
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mtkit
|
|
3
|
+
Version: 1.16.1
|
|
4
|
+
Summary: AI 全站测试工程师:计划先行生成标准 XMind 测试用例(质量门禁把关),用例资产体检修复,交互式测试咨询与问题定位指导,使用即训练、越用越成熟
|
|
5
|
+
Author: mtkit
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Keywords: testing,xmind,test-case,ai,qoder
|
|
8
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Topic :: Software Development :: Testing
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Requires-Python: >=3.8
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
Provides-Extra: docx
|
|
21
|
+
Requires-Dist: python-docx; extra == "docx"
|
|
22
|
+
Provides-Extra: mysql
|
|
23
|
+
Requires-Dist: pymysql; extra == "mysql"
|
|
24
|
+
Provides-Extra: all
|
|
25
|
+
Requires-Dist: python-docx; extra == "all"
|
|
26
|
+
Requires-Dist: pymysql; extra == "all"
|
|
27
|
+
|
|
28
|
+
# mtkit — AI 全站测试工程师
|
|
29
|
+
|
|
30
|
+
计划先行生成标准 XMind 测试用例(质量门禁把关),体检修复用例资产,交互式测试咨询与问题定位指导;使用即训练,越用越成熟。
|
|
31
|
+
|
|
32
|
+
## 流水线
|
|
33
|
+
|
|
34
|
+
```mermaid
|
|
35
|
+
flowchart LR
|
|
36
|
+
IN[输入: 方案.docx + 样例.xmind + 后端仓库 + 自定义文档] --> READ[读取与文档体检]
|
|
37
|
+
READ --> FACTS[代码事实扫描<br/>九语言接口/SQL]
|
|
38
|
+
FACTS --> PLAN[测试用例输出计划<br/>设计方法 + 构建者建议]
|
|
39
|
+
PLAN --> AUTH{授权}
|
|
40
|
+
AUTH -->|确认| CONTRACT[契约 JSON]
|
|
41
|
+
CONTRACT --> GATE[质量门禁<br/>review + AI 审查]
|
|
42
|
+
GATE --> RENDER[渲染 XMind]
|
|
43
|
+
RENDER --> CHECK[校验 + 漏测对比]
|
|
44
|
+
CHECK --> OUT[交付: XMind + 缺陷点汇总 + 工作痕迹]
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## 快速上手(零依赖)
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# 1. 生成 XMind(纯标准库,无需任何安装)
|
|
51
|
+
cd d:\mtkit
|
|
52
|
+
mtkit gen -i examples/sample.json -o 用例.xmind
|
|
53
|
+
|
|
54
|
+
# 2. 校验与统计
|
|
55
|
+
mtkit validate -i 用例.xmind
|
|
56
|
+
mtkit info -i 用例.xmind
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
可选依赖(用到才装):`.docx` 解析 `pip install python-docx`;数据库直连 `pip install pymysql`。
|
|
60
|
+
|
|
61
|
+
## 一键安装(含 Qoder 插件注册与可选依赖)
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# 方式一(推荐,新机器零门槛):PyPI 安装 CLI
|
|
65
|
+
pip install mtkit
|
|
66
|
+
|
|
67
|
+
# 方式二:仓库根目录执行(含可选依赖自动安装)
|
|
68
|
+
python install.py # 或双击 install.bat
|
|
69
|
+
|
|
70
|
+
# 方式三:输入 git 地址自动拉取安装
|
|
71
|
+
python install.py --git <git 地址> [--dir 目标目录]
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
安装完成后**重启 Qoder**,对话框输入 `/` 应列出 mtkit-gen-xmind,或直接自然语言触发。
|
|
75
|
+
|
|
76
|
+
> Qoder 插件注册:`skills/`、`commands/` 不在 PyPI 包中,pip 安装后执行
|
|
77
|
+
> `mtkit install --git <git 地址>`(或先设置环境变量 `MTKIT_INSTALL_GIT`)拉取完整仓库并注册插件。
|
|
78
|
+
|
|
79
|
+
## 命令
|
|
80
|
+
|
|
81
|
+
| 命令 | 作用 | 示例 |
|
|
82
|
+
|---|---|---|
|
|
83
|
+
| `gen` | 契约/数据 → .xmind | `mtkit gen -i 契约.json -o 用例.xmind` |
|
|
84
|
+
| `gather` | 方案+样例+代码 → 生成上下文 | `mtkit gather -i 方案.docx --hist 样例.xmind -r 后端 -o ctx.json` |
|
|
85
|
+
| `facts` | 九语言代码事实扫描 | `mtkit facts -r 后端 -o facts.json` |
|
|
86
|
+
| `review` | 契约质量门禁 | `mtkit review -i 契约.json -f facts.json` |
|
|
87
|
+
| `audit` | 用例资产体检(检索不合适用例) | `mtkit audit -i 旧用例.xmind -f facts.json` |
|
|
88
|
+
| `db` | 数据库只读接入(check/schema/verify) | `mtkit db verify -c db.json -i 契约.json` |
|
|
89
|
+
| `validate` / `info` | 校验 / 统计 .xmind | `mtkit validate -i 用例.xmind` |
|
|
90
|
+
| `diff` | 漏测对比 | `mtkit diff -i 用例.xmind -f facts.json -d 方案.docx` |
|
|
91
|
+
| `contract` / `tree` | 用例 ↔ 契约互转 / 还原树 | `mtkit contract -i 用例.xmind -o 契约.json` |
|
|
92
|
+
| `track` | 测试管理:执行记录/报告/趋势 | `mtkit track record --case 用例 --result pass` |
|
|
93
|
+
| `bug` | 缺陷库:登记/清单/关闭/统计 | `mtkit bug add --title 缺陷 --severity P1` |
|
|
94
|
+
| `evolve` | 自进化:备份/恢复/清单/清理 | `mtkit evolve backup 文件` |
|
|
95
|
+
| `asset` | 用例资产老化检测(治理) | `mtkit asset --dir 输出目录 --days 30` |
|
|
96
|
+
|
|
97
|
+
契约格式(唯一输入约定):
|
|
98
|
+
|
|
99
|
+
```json
|
|
100
|
+
{"chapters":[{"t":"章节","cases":[{"t":"tc-P0-功能测试:用例名",
|
|
101
|
+
"pc":["前置"],"steps":["步骤"],"expects":["预期"],"sql":["SELECT ..."]}]}]}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## 数据库接入(可选,严格只读)
|
|
105
|
+
|
|
106
|
+
`db.json` 四种数据源(`type` 字段):
|
|
107
|
+
|
|
108
|
+
```json
|
|
109
|
+
{"type":"cli","connect":{"cmd":"mysql -h{host} -u{user} -p{pass} {db} -N -e \"{sql}\"","host":"10.0.0.1","user":"ro","pass":"${DB_PASS}","db":"bill_db"}}
|
|
110
|
+
{"type":"driver","driver":"pymysql","host":"10.0.0.1","user":"ro","password":"${DB_PASS}","db":"bill_db"}
|
|
111
|
+
{"type":"http","url":"https://gw.example.com/query","token":"${DB_TOKEN}"}
|
|
112
|
+
{"type":"file","path":"schema.json"}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
仅允许 SELECT/EXPLAIN/DESC/SHOW;写操作一律拒绝。密码用 `${ENV_VAR}` 环境变量。
|
|
116
|
+
|
|
117
|
+
## Qoder 集成(2 步)
|
|
118
|
+
|
|
119
|
+
1. Qoder 插件管理 → 本地插件 → 选择 `d:\mtkit`
|
|
120
|
+
2. 对话输入:
|
|
121
|
+
- 生成用例:"用 mtkit 生成 XMind 测试用例:方案 xxx.docx,样例 xxx.xmind,后端仓库 xxx"
|
|
122
|
+
- 测试咨询:"这个功能怎么测?" / "线上报错了帮我看看" / "是不是 bug?"
|
|
123
|
+
|
|
124
|
+
## 技能时序
|
|
125
|
+
|
|
126
|
+
```mermaid
|
|
127
|
+
sequenceDiagram
|
|
128
|
+
participant U as 使用者
|
|
129
|
+
participant A as AI(测试构建者)
|
|
130
|
+
U->>A: 输入三件套 + 可选文档/db
|
|
131
|
+
A->>U: 文档体检(缺陷点+建议,逐条确认)
|
|
132
|
+
A->>A: gather + facts + 经验库加载
|
|
133
|
+
A->>U: 测试用例输出计划(设计方法+构建者建议)
|
|
134
|
+
U->>A: 授权(可增删调整)
|
|
135
|
+
A->>A: 生成契约 → 质量门禁 → 修正循环
|
|
136
|
+
A->>U: 用例调整建议(逐条确认)
|
|
137
|
+
A->>A: 渲染 XMind → 校验 → 漏测对比
|
|
138
|
+
A->>U: 交付(XMind/缺陷点汇总/工作痕迹)+ 训练沉淀
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## 迭代更新(editable 安装,无需重装)
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
pip install --force-reinstall --no-deps -e d:\mtkit # 仅在需要时
|
|
145
|
+
python -m unittest # 自检
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
- 插件侧:仓库文件更新即生效,仅 plugin.json 版本变化需重启 Qoder
|
|
149
|
+
- **自我迭代**:AI 使用中发现改进点会写入 `.mtkit-work/improvements.json`;在 `.mtkit.json` 开启 `auto_improve` 并授权后,AI 可自行优化并自验(详见 skills 文档)
|
|
150
|
+
- 详细说明:见 [CHANGELOG.md](CHANGELOG.md)、[skills/mtkit-gen-xmind/](skills/mtkit-gen-xmind/)(技能与规范)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
mtkit/__init__.py,sha256=0i5egXQj45wZJiHqHAutXuZeRRC8fepx-S14US--E2A,1649
|
|
2
|
+
mtkit/__main__.py,sha256=YgGw3jK72Pu3VX9zLP3Y2aUbwpfeKQbmX8GOFrd-rSA,117
|
|
3
|
+
mtkit/asset.py,sha256=OPUCmL8NShzqBNnzTZOw07JKcrkZmIe3cdMvVGBkzc8,3670
|
|
4
|
+
mtkit/audit.py,sha256=ayfC8cBKDGy6AsjhpdlaPwaCgBrEl0M8HJynUaPKOaw,9009
|
|
5
|
+
mtkit/builder.py,sha256=sgwXTHNgH48VMvJyaVHjra0Moyz0lZ_2ffkZvZa0Xdc,3000
|
|
6
|
+
mtkit/cli.py,sha256=Xi0WnOFLnsoL2fcdVrDXYiZzEjp7zw0IP95IMhKkdEY,41479
|
|
7
|
+
mtkit/conf.py,sha256=dNo9lTwmJsS8MQXmSkiPLdVU2QXyqiauRrhAmFxOO-U,2035
|
|
8
|
+
mtkit/coverage.py,sha256=vhUoRi7Kh8Xs2tPS1yJ5j2KMCXxWGG0nJkYtxjfcb6w,6582
|
|
9
|
+
mtkit/db.py,sha256=TtQt97gjdBmHvGezvwXGXNJUP_H7mH7UrhWXQlNc6eY,26724
|
|
10
|
+
mtkit/evolve.py,sha256=DdSRXQKmvWfNZa8WdgB4VJMJ4G7wW_QFYO7tRTxnWgU,5559
|
|
11
|
+
mtkit/normalize.py,sha256=gzO8eqauBr2DMQqv7pOZecXbg-5-HTrWvIT7ODnYMdo,19449
|
|
12
|
+
mtkit/parsers.py,sha256=xk-Aq6yPnbOunjaKCWyERZT51w5X40LpKlUIPWn7hds,11873
|
|
13
|
+
mtkit/review.py,sha256=-4-HjlfZZ9sGeZe7mYRPJOcOnfyj-g_PH1NPnZKh4Ys,11485
|
|
14
|
+
mtkit/selfheal.py,sha256=KiQMTmTndqUTCzToHzGUWj9IG-i-8ezYb1nZNOcKGwI,3696
|
|
15
|
+
mtkit/tb.py,sha256=ufPG3moS8vo-BfE5sEmlqgVtbf5zuO9JEpZLOkal1h8,7514
|
|
16
|
+
mtkit/track.py,sha256=HuBcyM9D33NF8FxuWVvm4iGZUXrqpgNhOG-5rLn2h3M,11172
|
|
17
|
+
mtkit/validator.py,sha256=vFQWHktWMBvop30zKesE--t8qqirEmlQhCjagOA8NPo,6934
|
|
18
|
+
mtkit/writer.py,sha256=xEKG27kvfl_I5v0J9_6siDV4L-J7brhkIq09nYTjCjc,4833
|
|
19
|
+
mtkit/extract/__init__.py,sha256=PORSFJzKik8ULQlYMAvL47TmRchi6eT-I7pxwlG8gdc,567
|
|
20
|
+
mtkit/extract/code_facts.py,sha256=lrKn0_M3xpOsQbLHhgljX8UEKSDnsTyRkGbbW7Jd_1I,25499
|
|
21
|
+
mtkit/extract/docx_loader.py,sha256=ZUUIi4osIzRVmUrojSyrEbZz-JHU2XLq6Z8OpvURthM,4344
|
|
22
|
+
mtkit/extract/xmind_loader.py,sha256=8OpNHft6BiGRJWgNTH_q4inmQgqt7jKrcCsOEZLNHHA,4084
|
|
23
|
+
mtkit/generate/__init__.py,sha256=fKIO6wXxFzNOj699qpLpyQED1ez8WJxb7rn5aWkV64c,276
|
|
24
|
+
mtkit/generate/llm.py,sha256=DeMEZmZhq-4NjIy9Bdcs0K-WlSpAN9ZBaowKnxzNO30,14688
|
|
25
|
+
mtkit/generate/prompts.py,sha256=DqprgMjcIpC-73xyjG_EJ_yz3f69HSkNUNOPMMUxpuQ,8652
|
|
26
|
+
mtkit/generate/skeleton.py,sha256=re0wu7YfaSjopHWMAIZ4ESczgyRFlb-8NPzE4Q51YX8,2314
|
|
27
|
+
mtkit-1.16.1.dist-info/METADATA,sha256=4MPjJH5H1F6mE3F2FBza1oxWKqy-311-WD8KCCn8qSA,6617
|
|
28
|
+
mtkit-1.16.1.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
29
|
+
mtkit-1.16.1.dist-info/entry_points.txt,sha256=xRgj9efDAE4lrSBUSHdi2kNrZCi6_IkY0ghlgDtRlu8,41
|
|
30
|
+
mtkit-1.16.1.dist-info/top_level.txt,sha256=v_Jex0ASYYotl9-9y2_nV2KT-2EMYhbCdftZFhev6t8,6
|
|
31
|
+
mtkit-1.16.1.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
mtkit
|