feat: 测试开发学习路径上线阶段 1 前两个模块(26 章 / 117 小节),工具链支持多阶段
- 新增 modules/s1-01-case-design/(测试理论与用例设计,13 章 / 59 小节) - 新增 modules/s1-02-http-api/(HTTP 接口与接口测试基础,13 章 / 58 小节) - tools/modules-plan.json 改为按阶段组织,阶段 1 的 4 个模块全部登记(未开工的两个标「筹备中」跳过) - tools/build-module-index.js 支持多阶段,上一/下一模块按全书顺序跨阶段衔接(数据库 → 测试理论与用例设计) - 新增 tools/check-chapter.js:单章自检(结构 / 章号 / 代码块 / 表格 / 锚点),支持 --strict 校验侧栏同步 - assets/doc.css 补 .box.pit 样式;index.html 登记 s1-0 / s1-1 路由;README 更新进度与工具说明
This commit is contained in:
@@ -1,14 +1,22 @@
|
||||
#!/usr/bin/env node
|
||||
/* ==========================================================================
|
||||
模块目录页生成器(阶段 0)
|
||||
模块目录页生成器(全部阶段)
|
||||
用法:node tools/build-module-index.js [站点根目录,默认本文件的上一级]
|
||||
|
||||
作用:读取 tools/modules-plan.json 里的模块级元数据(标题 / 副标题 / 导语 /
|
||||
建议投入 / 前后模块),再扫描 modules/<dir>/NN-*.html 解析出每章的 h2 标题与
|
||||
全部 h3 小节,生成模块目录页 modules/<dir>/index.html。
|
||||
建议投入),再扫描 modules/<dir>/NN-*.html 解析出每章的 h2 标题与全部 h3 小节,
|
||||
生成模块目录页 modules/<dir>/index.html。
|
||||
|
||||
为什么章节标题不写在 plan 里:目录页与正文必须永远一致。从正文解析,
|
||||
就不会出现「改了正文章节标题、目录页还是旧的」这类问题。
|
||||
|
||||
跳过规则:plan 里列了、但目录不存在或没有 NN-*.html 的模块视为「筹备中」,
|
||||
照样参与编号与前后模块关系(上一/下一模块会指向它,并标注「筹备中」)。
|
||||
这样阶段与模块的编号永远和 index.html 的 STAGES 对齐,不会因为先写哪个模块而错位。
|
||||
|
||||
上一 / 下一模块按「全书展平顺序」计算,跨阶段也连续:
|
||||
阶段 0 最后一个模块 → 阶段 1 第一个模块。
|
||||
|
||||
幂等:可重复运行;生成后建议再跑一次 tools/build-nav.js 同步侧栏目录树。
|
||||
========================================================================== */
|
||||
const fs = require("fs");
|
||||
@@ -35,31 +43,49 @@ const plain = s => decode(stripTags(s));
|
||||
const stripNo = s => s.replace(/^\s*\d+(?:\.\d+)*\s*[\.、]?\s*/, "").trim();
|
||||
|
||||
const plan = readPlan(PLAN);
|
||||
const stage = plan.stage;
|
||||
const mods = plan.modules;
|
||||
const stages = plan.stages;
|
||||
const brand = plan.brand;
|
||||
|
||||
/* ---------- 逐模块生成 ---------- */
|
||||
let written = 0;
|
||||
const report = [];
|
||||
|
||||
mods.forEach((m, mi) => {
|
||||
const modPath = path.join(MODDIR, m.dir);
|
||||
if (!fs.existsSync(modPath)) throw new Error(`模块目录不存在:modules/${m.dir}`);
|
||||
|
||||
const files = fs.readdirSync(modPath).filter(f => /^\d\d-.*\.html$/.test(f)).sort();
|
||||
if (!files.length) throw new Error(`modules/${m.dir} 下没有 NN-*.html 章节页`);
|
||||
|
||||
const chapters = files.map(file => {
|
||||
const html = fs.readFileSync(path.join(modPath, file), "utf8");
|
||||
const h2 = html.match(/<h2 id="[^"]*">([\s\S]*?)<\/h2>/);
|
||||
if (!h2) throw new Error(`modules/${m.dir}/${file}: 找不到 h2 章节标题`);
|
||||
const title = plain(h2[1].replace(/<span class="n">\d+<\/span>/, ""));
|
||||
const sections = [...html.matchAll(/<h3 id="([^"]+)">([\s\S]*?)<\/h3>/g)]
|
||||
.map(x => ({ id: x[1], label: stripNo(plain(x[2])) }));
|
||||
// 字数口径:只统计中文汉字(代码与英文命令不计入「千字」,否则会被严重高估)
|
||||
const chars = (stripTags(html).match(/[\u4e00-\u9fff]/g) || []).length;
|
||||
return { file, title, sections, chars };
|
||||
/* ---------- 1. 扫描:每个模块能否生成 ---------- */
|
||||
const slots = []; // 全展平,顺序 = 阶段顺序 + 模块下标顺序
|
||||
stages.forEach((st, si) => {
|
||||
if (!st.modules) st.modules = [];
|
||||
st.modules.forEach((m, mi) => {
|
||||
const modPath = path.join(MODDIR, m.dir);
|
||||
const files = fs.existsSync(modPath)
|
||||
? fs.readdirSync(modPath).filter(f => /^\d\d-.*\.html$/.test(f)).sort()
|
||||
: [];
|
||||
let chapters = null;
|
||||
if (files.length) {
|
||||
chapters = files.map(file => {
|
||||
const html = fs.readFileSync(path.join(modPath, file), "utf8");
|
||||
const h2 = html.match(/<h2 id="[^"]*">([\s\S]*?)<\/h2>/);
|
||||
if (!h2) throw new Error(`modules/${m.dir}/${file}: 找不到 h2 章节标题`);
|
||||
const title = plain(h2[1].replace(/<span class="n">\d+<\/span>/, ""));
|
||||
const sections = [...html.matchAll(/<h3 id="([^"]+)">([\s\S]*?)<\/h3>/g)]
|
||||
.map(x => ({ id: x[1], label: stripNo(plain(x[2])) }));
|
||||
// 字数口径:只统计中文汉字(代码与英文命令不计入「千字」,否则会被严重高估)
|
||||
const chars = (stripTags(html).match(/[\u4e00-\u9fff]/g) || []).length;
|
||||
return { file, title, sections, chars };
|
||||
});
|
||||
}
|
||||
slots.push({ st, si, m, mi, modPath, chapters, files });
|
||||
});
|
||||
});
|
||||
|
||||
const built = slots.filter(s => s.chapters);
|
||||
const report = [];
|
||||
let written = 0;
|
||||
|
||||
/* ---------- 2. 逐模块生成 ---------- */
|
||||
built.forEach((slot, gi) => {
|
||||
const { st, m, mi, modPath, chapters } = slot;
|
||||
const prevSlot = gi > 0 ? built[gi - 1] : null;
|
||||
const nextSlot = gi < built.length - 1 ? built[gi + 1] : null;
|
||||
// 本阶段的下一个模块(可能还没写)
|
||||
const nextInStage = nextSlot && nextSlot.st === st
|
||||
? nextSlot
|
||||
: slots.find(s => s.st === st && s.mi === mi + 1) || null;
|
||||
|
||||
const chapItems = chapters.map((c, i) => {
|
||||
const secs = c.sections.length
|
||||
@@ -77,19 +103,32 @@ mods.forEach((m, mi) => {
|
||||
const totalSecs = chapters.reduce((n, c) => n + c.sections.length, 0);
|
||||
const totalK = Math.round(chapters.reduce((n, c) => n + c.chars, 0) / 1000);
|
||||
|
||||
const prev = mi === 0
|
||||
? { href: `${plan.brand.home}#${stage.id}`, k: "← 上一模块", v: `已经是阶段 0 的第一个模块` }
|
||||
: { href: `../${mods[mi - 1].dir}/index.html`, k: "← 上一模块", v: mods[mi - 1].title };
|
||||
const next = mi === mods.length - 1
|
||||
? { href: `${plan.brand.home}#${stage.id}`, k: "阶段 0 完成 →", v: "回到学习路径,进入阶段 1 · 会测" }
|
||||
: { href: `../${mods[mi + 1].dir}/index.html`, k: "下一模块 →", v: mods[mi + 1].title };
|
||||
const prev = prevSlot
|
||||
? { href: `../${prevSlot.m.dir}/index.html`, k: "← 上一模块", v: prevSlot.m.title }
|
||||
: { href: `${brand.home}#${st.id}`, k: "← 上一模块", v: `本阶段(${st.anchorText})的第一个模块` };
|
||||
|
||||
let next;
|
||||
if (nextSlot) {
|
||||
next = {
|
||||
href: `../${nextSlot.m.dir}/index.html`,
|
||||
k: nextSlot.st === st ? "下一模块 →" : `${nextSlot.st.anchorText} →`,
|
||||
v: nextSlot.m.title
|
||||
};
|
||||
} else if (nextInStage) {
|
||||
next = { href: `${brand.home}#${st.id}`, k: "下一模块 →", v: `筹备中:${nextInStage.m.title}` };
|
||||
} else if (stages[slot.si + 1]) {
|
||||
const nx = stages[slot.si + 1];
|
||||
next = { href: `${brand.home}#${nx.id}`, k: `${nx.anchorText} →`, v: `回到学习路径,进入${nx.anchorText}` };
|
||||
} else {
|
||||
next = { href: `${brand.home}#${st.id}`, k: "学习路径 →", v: "回到学习路径" };
|
||||
}
|
||||
|
||||
const html = `<!DOCTYPE html>
|
||||
<html lang="zh-CN" data-theme="light">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>${esc(m.title)} · ${stage.anchorText} 模块 ${mi + 1} · ${esc(plan.brand.siteName)}</title>
|
||||
<title>${esc(m.title)} · ${st.anchorText} 模块 ${mi + 1} · ${esc(brand.siteName)}</title>
|
||||
<meta name="description" content="${esc(m.title)} 模块目录:共 ${chapters.length} 章、${totalSecs} 个小节。">
|
||||
<link rel="stylesheet" href="../../assets/doc.css">
|
||||
</head>
|
||||
@@ -97,10 +136,10 @@ mods.forEach((m, mi) => {
|
||||
|
||||
<header class="topbar">
|
||||
<div class="tb-in">
|
||||
<a class="brand" href="${plan.brand.home}"><span class="logo">${esc(plan.brand.logo)}</span><div>从零到成熟<small>测试开发 · 模块详解</small></div></a>
|
||||
<a class="brand" href="${brand.home}"><span class="logo">${esc(brand.logo)}</span><div>从零到成熟<small>测试开发 · 模块详解</small></div></a>
|
||||
<div class="crumbs">
|
||||
<a href="${plan.brand.home}">学习路径</a><span class="sep">/</span>
|
||||
<a href="${plan.brand.home}#${stage.id}">${esc(stage.anchorText)}</a><span class="sep">/</span>
|
||||
<a href="${brand.home}">学习路径</a><span class="sep">/</span>
|
||||
<a href="${brand.home}#${st.id}">${esc(st.anchorText)}</a><span class="sep">/</span>
|
||||
<b>${esc(m.title)}</b>
|
||||
</div>
|
||||
<div class="spacer"></div>
|
||||
@@ -115,7 +154,7 @@ mods.forEach((m, mi) => {
|
||||
<nav id="chapters"></nav>
|
||||
<div class="side-foot">
|
||||
<a class="btn" href="index.html">← 模块目录</a>
|
||||
<a class="btn" href="${plan.brand.home}">学习路径</a>
|
||||
<a class="btn" href="${brand.home}">学习路径</a>
|
||||
</div>
|
||||
</aside>
|
||||
<div class="mask" id="mask"></div>
|
||||
@@ -123,7 +162,7 @@ mods.forEach((m, mi) => {
|
||||
<main class="main-col">
|
||||
<article>
|
||||
<div class="modhero">
|
||||
<span class="mh-no">${stage.anchorText} · 模块 ${mi + 1} / ${mods.length}</span>
|
||||
<span class="mh-no">${esc(st.anchorText)} · 模块 ${mi + 1} / ${st.modules.length}</span>
|
||||
<h1>${esc(m.title)}</h1>
|
||||
<p class="mh-sub">${esc(m.sub)}</p>
|
||||
<div class="mh-meta">
|
||||
@@ -157,7 +196,7 @@ ${chapItems}
|
||||
|
||||
<p class="foot">
|
||||
${esc(m.title)} · 模块目录<br>
|
||||
<a href="${plan.brand.home}">返回学习路径</a>
|
||||
<a href="${brand.home}">返回学习路径</a>
|
||||
</p>
|
||||
</main>
|
||||
</div>
|
||||
@@ -174,5 +213,8 @@ ${chapItems}
|
||||
report.push(`modules/${m.dir}/index.html:${chapters.length} 章 / ${totalSecs} 小节 / 约 ${totalK} 千字`);
|
||||
});
|
||||
|
||||
const pending = slots.filter(s => !s.chapters);
|
||||
pending.forEach(s => report.push(`modules/${s.m.dir}/(筹备中,跳过):${s.st.anchorText} 模块 ${s.mi + 1} ${s.m.title}`));
|
||||
|
||||
console.log(report.join("\n"));
|
||||
console.log(`\n共生成 ${written} 个模块目录页。下一步:node tools/build-nav.js`);
|
||||
console.log(`\n共生成 ${written} 个模块目录页(筹备中跳过 ${pending.length} 个)。下一步:node tools/build-nav.js`);
|
||||
|
||||
186
测试开发工程师/testdev-learning-path/tools/check-chapter.js
Normal file
186
测试开发工程师/testdev-learning-path/tools/check-chapter.js
Normal file
@@ -0,0 +1,186 @@
|
||||
#!/usr/bin/env node
|
||||
/* ==========================================================================
|
||||
单章 / 单模块自检:给「正在写这一章」的人一个即时反馈,不必跑全站自检
|
||||
用法:
|
||||
node tools/check-chapter.js modules/s1-01-case-design/03-equiv.html
|
||||
node tools/check-chapter.js modules/s1-01-case-design # 整个模块
|
||||
node tools/check-chapter.js modules/s1-01-case-design/03-equiv.html --strict
|
||||
参数可以是文件或目录(目录会检查其中所有 NN-*.html),路径相对本工具上一级。
|
||||
|
||||
与 tools/check-pages.js 的关系:这里只检查「单个页面自己能负责」的部分
|
||||
(结构、格式、章号、锚点、链接),侧栏目录树一致性等跨页面项目仍然由
|
||||
check-pages.js 在跑完 build-nav.js 之后统一检查。
|
||||
|
||||
--strict 额外要求:本章所有小节都在侧栏目录树里出现(写完并跑过 build-nav.js 之后用)。
|
||||
========================================================================== */
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
const root = path.resolve(__dirname, "..");
|
||||
const args = process.argv.slice(2);
|
||||
const STRICT = args.includes("--strict");
|
||||
const targets = args.filter(a => !a.startsWith("--"));
|
||||
if (!targets.length) {
|
||||
console.error("用法:node tools/check-chapter.js <章节页或模块目录> [--strict]");
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
const ALLOWED_BOX = new Set(["", "note", "tip", "warn", "danger", "ok", "case", "lab", "pit"]);
|
||||
const TAG_PAIRS = ["div", "section", "article", "aside", "nav", "main", "details", "table",
|
||||
"ul", "ol", "li", "thead", "tbody", "tr", "td", "th", "pre", "p", "span"];
|
||||
|
||||
const problems = [];
|
||||
const notes = [];
|
||||
|
||||
function walkHtml(dir, out = []) {
|
||||
for (const e of fs.readdirSync(dir, { withFileTypes: true })) {
|
||||
const p = path.join(dir, e.name);
|
||||
if (e.isDirectory()) { if (e.name !== "assets" && e.name !== "tools") walkHtml(p, out); }
|
||||
else if (e.name.endsWith(".html")) out.push(p);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/* 站内 id 索引:用于校验锚点是否真实存在 */
|
||||
const idIndex = new Map();
|
||||
for (const p of walkHtml(root)) {
|
||||
const html = fs.readFileSync(p, "utf8");
|
||||
const ids = new Set([...html.matchAll(/\sid="([^"]+)"/g)].map(m => m[1]));
|
||||
if (path.resolve(p) === path.resolve(root, "index.html")) {
|
||||
[...html.matchAll(/^\s*id:"([^"]+)"/gm)].forEach(m => ids.add(m[1]));
|
||||
}
|
||||
idIndex.set(path.resolve(p), ids);
|
||||
}
|
||||
|
||||
/* 展开待检查文件 */
|
||||
const files = [];
|
||||
for (const t of targets) {
|
||||
const p = path.resolve(root, t);
|
||||
if (!fs.existsSync(p)) { console.error(`路径不存在:${t}`); process.exit(2); }
|
||||
if (fs.statSync(p).isDirectory()) {
|
||||
const f = fs.readdirSync(p).filter(x => /^\d\d-.*\.html$/.test(x)).sort();
|
||||
if (!f.length) { console.error(`${t} 下没有 NN-*.html`); process.exit(2); }
|
||||
f.forEach(x => files.push(path.join(p, x)));
|
||||
} else files.push(p);
|
||||
}
|
||||
|
||||
for (const p of files) {
|
||||
const rel = path.relative(root, p).replace(/\\/g, "/");
|
||||
const html = fs.readFileSync(p, "utf8");
|
||||
const markup = html.replace(/<script[\s\S]*?<\/script>/g, "");
|
||||
const must = (c, m) => { if (!c) problems.push(`${rel}: ${m}`); };
|
||||
|
||||
if (!/^modules\/[^/]+\/\d\d-/.test(rel)) {
|
||||
notes.push(`${rel}:不是章节页,只做结构检查`);
|
||||
} else {
|
||||
const chapNo = parseInt(path.basename(rel).slice(0, 2), 10);
|
||||
const modPath = path.dirname(p);
|
||||
const modFiles = fs.readdirSync(modPath).filter(f => /^\d\d-.*\.html$/.test(f)).sort();
|
||||
|
||||
must(html.includes("<article>"), "缺少 article");
|
||||
must(html.includes('id="chapters"'), "缺少章节目录侧栏 #chapters");
|
||||
must(/<h2 id="/.test(html), "缺少 h2 章节标题");
|
||||
must(html.includes('class="chapnav"'), "缺少章节目录定位条 chapnav");
|
||||
must(html.includes('class="pager"'), "缺少上一/下一章 pager");
|
||||
must(html.includes('href="index.html"'), "缺少返回模块目录链接");
|
||||
must(html.includes('href="../../assets/doc.css"'), "doc.css 路径不对");
|
||||
must(html.includes('src="../../assets/doc.js"'), "doc.js 路径不对");
|
||||
must(/assets\/back\.js/.test(html), "缺少返回资料库入口 back.js");
|
||||
|
||||
// chapnav:章号 / 总章数 / 小节数
|
||||
const navPos = html.match(/第 <b class="pos">(\d+)<\/b> \/ (\d+) 章/);
|
||||
if (!navPos) problems.push(`${rel}: chapnav 缺少「第 N / M 章」`);
|
||||
else {
|
||||
if (Number(navPos[1]) !== chapNo) problems.push(`${rel}: chapnav 章号 ${navPos[1]} ≠ 文件名 ${chapNo}`);
|
||||
if (Number(navPos[2]) !== modFiles.length) problems.push(`${rel}: chapnav 总章数 ${navPos[2]} ≠ 目录实际 ${modFiles.length} 章`);
|
||||
}
|
||||
const h3all = html.match(/<h3[ >]/g) || [];
|
||||
const h3withId = html.match(/<h3 id="/g) || [];
|
||||
must(h3withId.length === h3all.length, `有 h3 未补 id(${h3withId.length}/${h3all.length})`);
|
||||
const navSecs = html.match(/本章 (\d+) 小节/);
|
||||
if (h3all.length && !navSecs) problems.push(`${rel}: 有 ${h3all.length} 个小节但 chapnav 未写「本章 N 小节」`);
|
||||
if (navSecs && Number(navSecs[1]) !== h3all.length) problems.push(`${rel}: chapnav 小节数 ${navSecs[1]} ≠ 实际 ${h3all.length}`);
|
||||
|
||||
// h3 编号与 id
|
||||
for (const h of html.matchAll(/<h3 id="([^"]+)">([\s\S]*?)<\/h3>/g)) {
|
||||
if (!/^sec-(x)?\d/.test(h[1]) && !/^sec-\d+-\d+$/.test(h[1])) problems.push(`${rel}: h3 id 命名不规范 ${h[1]}`);
|
||||
const label = h[2].replace(/<[^>]+>/g, "").replace(/\s+/g, " ").trim();
|
||||
if (!new RegExp(`^${chapNo}\\.\\d+`).test(label)) {
|
||||
problems.push(`${rel}: h3「${label.slice(0, 30)}」编号与章号不一致(应为 ${chapNo}.x)`);
|
||||
}
|
||||
}
|
||||
|
||||
// 当前章在目录树里必须是 active(非空目录树时)
|
||||
const nav = html.match(/<nav id="chapters">([\s\S]*?)<\/nav>/);
|
||||
if (!nav) problems.push(`${rel}: 缺少 #chapters 目录树`);
|
||||
else if (nav[1].trim()) {
|
||||
must(/class="toc-a active"[^>]*aria-current="page"/.test(html), "当前章未在目录树标 active");
|
||||
const cur = nav[1].match(/<div class="subnav current">([\s\S]*?)<\/div>/);
|
||||
const curSecs = cur ? (cur[1].match(/class="toc-a lv3"/g) || []).length : 0;
|
||||
if (STRICT && curSecs !== h3all.length) problems.push(`${rel}: 本章目录树小节 ${curSecs} ≠ 正文 ${h3all.length}(需要重跑 build-nav.js)`);
|
||||
const rows = (nav[1].match(/class="toc-a( active)?"/g) || []).length;
|
||||
must(rows === modFiles.length, `目录树章节数 ${rows} ≠ 目录实际 ${modFiles.length}`);
|
||||
for (const f of modFiles) {
|
||||
if (f === path.basename(p)) continue;
|
||||
must(nav[1].includes(`href="${f}"`), `目录树缺少章节 ${f}`);
|
||||
}
|
||||
} else {
|
||||
notes.push(`${rel}:目录树为空,跑 build-nav.js 后会自动填充`);
|
||||
}
|
||||
}
|
||||
|
||||
must(/<title>[^<]+<\/title>/.test(html), "缺少 title");
|
||||
must(!/<style[\s>]/.test(markup), "不应出现 <style> 标签");
|
||||
const inline = (markup.match(/\sstyle="/g) || []).length;
|
||||
must(!inline, `有 ${inline} 处内联 style`);
|
||||
|
||||
// 代码块
|
||||
const pres = markup.match(/<pre[\s\S]*?<\/pre>/g) || [];
|
||||
pres.forEach((blk, i) => {
|
||||
if (!/data-lang=/.test(blk)) problems.push(`${rel}: 第 ${i + 1} 个 <pre> 未标注 data-lang`);
|
||||
const body = blk.replace(/^<pre[^>]*>/, "").replace(/<\/pre>$/, "");
|
||||
if (/</.test(body)) problems.push(`${rel}: 第 ${i + 1} 个 <pre> 内有未转义的 <`);
|
||||
});
|
||||
|
||||
// 提示框 / 表格
|
||||
for (const m of markup.matchAll(/<div class="box([^"]*)"/g)) {
|
||||
for (const cls of m[1].trim().split(/\s+/).filter(Boolean)) {
|
||||
if (!ALLOWED_BOX.has(cls)) problems.push(`${rel}: 提示框用了不在规范内的类 box.${cls}`);
|
||||
}
|
||||
}
|
||||
const tables = (markup.match(/<table[\s>]/g) || []).length;
|
||||
const wrapped = (markup.match(/class="tablewrap"/g) || []).length;
|
||||
must(tables === wrapped, `表格 ${tables} 个,tablewrap 包裹 ${wrapped} 个`);
|
||||
|
||||
// 标签配对
|
||||
for (const t of TAG_PAIRS) {
|
||||
const o = (markup.match(new RegExp("<" + t + "(?=[\\s>])", "g")) || []).length;
|
||||
const c = (markup.match(new RegExp("</" + t + ">", "g")) || []).length;
|
||||
if (o !== c) problems.push(`${rel}: <${t}> 开合不匹配 ${o}/${c}`);
|
||||
}
|
||||
|
||||
// 残留占位
|
||||
if (/<!--\s*(MORE|TODO|PART\d|占位)/i.test(html)) problems.push(`${rel}: 有未完成的占位注释`);
|
||||
|
||||
// 链接与锚点
|
||||
const links = [...markup.matchAll(/href="(?!https?:|mailto:)([^"]+)"/g)].map(m => m[1]);
|
||||
for (const l of new Set(links)) {
|
||||
const [file, hash] = l.split("#");
|
||||
const target = file ? path.resolve(path.dirname(p), file) : path.resolve(p);
|
||||
if (file && !fs.existsSync(target)) { problems.push(`${rel}: 死链 ${l}`); continue; }
|
||||
if (hash && idIndex.has(target) && !idIndex.get(target).has(hash)) {
|
||||
problems.push(`${rel}: 锚点不存在 ${l}`);
|
||||
}
|
||||
}
|
||||
|
||||
const cn = (markup.replace(/<pre[\s\S]*?<\/pre>/g, "").match(/[\u4e00-\u9fff]/g) || []).length;
|
||||
notes.push(`${rel}:正文汉字约 ${cn},代码块 ${pres.length},表格 ${tables}`);
|
||||
}
|
||||
|
||||
notes.forEach(n => console.log("· " + n));
|
||||
if (problems.length) {
|
||||
console.error(`\n发现 ${problems.length} 个问题:`);
|
||||
problems.forEach(x => console.error(" - " + x));
|
||||
process.exit(1);
|
||||
}
|
||||
console.log(`\nOK:${files.length} 个页面检查通过`);
|
||||
@@ -1,51 +1,96 @@
|
||||
/* ==========================================================================
|
||||
阶段 0 模块元数据
|
||||
模块元数据(按阶段组织)
|
||||
用途:tools/build-module-index.js 依据本文件生成每个模块的目录页(index.html)。
|
||||
章节标题与小节标题不写在这里 —— 目录页直接从章节 HTML 里解析,保证与正文永远一致;
|
||||
本文件只维护「模块级」信息:标题、副标题、建议投入、导语、前后模块关系。
|
||||
新增模块:追加一个对象,然后在 index.html 的 PAGES 表里登记路由。
|
||||
本文件只维护「模块级」信息:标题、副标题、建议投入、导语。
|
||||
|
||||
新增模块:在对应阶段的 modules 里追加一个对象(dir 必须与 modules/ 下的目录同名),
|
||||
然后在 index.html 的 PAGES 表里登记路由(key = 阶段 id + "-" + 模块在数组里的下标)。
|
||||
|
||||
还没开始写的模块照样可以留在数组里:目录不存在或没有章节页时,
|
||||
build-module-index.js 会跳过它并在输出里标「筹备中」,不会报错。
|
||||
数组顺序 = 模块编号顺序,不要随意重排。
|
||||
========================================================================== */
|
||||
{
|
||||
"stage": {
|
||||
"id": "s0",
|
||||
"num": "0",
|
||||
"title": "打地基",
|
||||
"sub": "计算机 · Go 工程 · Linux · 数据库",
|
||||
"anchorText": "阶段 0 · 打地基"
|
||||
},
|
||||
"brand": {
|
||||
"logo": "QA",
|
||||
"siteName": "测试开发工程师从零到成熟",
|
||||
"home": "../../index.html"
|
||||
},
|
||||
"modules": [
|
||||
"stages": [
|
||||
{
|
||||
"dir": "s0-01-network",
|
||||
"title": "计算机与网络基础",
|
||||
"sub": "进程 · TCP · HTTP · 抓包 · 调用链",
|
||||
"hours": "建议投入 18–24 小时",
|
||||
"lead": "<b>模块定位:</b>阶段 0 的第 1 个模块。测试工程师 80% 的争论都发生在「这到底是谁的问题」上,而这类争论几乎都能用系统与网络的知识终结。<br><br><b>学完之后你应该能:</b>给一个「页面报 500 / 接口偶发超时」的现场,在 10 分钟内判断是前端、网络、网关还是后端的问题,并说清判断依据;能对任意一个被测接口画出从浏览器到数据库的调用链。<br><br><b>学习方式:</b>一半时间在敲命令(curl、ss、tcpdump、mitmproxy),一半时间在画图和归因。看懂一次真实抓包,胜过读十篇文章。"
|
||||
"id": "s0",
|
||||
"num": "0",
|
||||
"title": "打地基",
|
||||
"sub": "计算机 · Go 工程 · Linux · 数据库",
|
||||
"anchorText": "阶段 0 · 打地基",
|
||||
"modules": [
|
||||
{
|
||||
"dir": "s0-01-network",
|
||||
"title": "计算机与网络基础",
|
||||
"sub": "进程 · TCP · HTTP · 抓包 · 调用链",
|
||||
"hours": "建议投入 18–24 小时",
|
||||
"lead": "<b>模块定位:</b>阶段 0 的第 1 个模块。测试工程师 80% 的争论都发生在「这到底是谁的问题」上,而这类争论几乎都能用系统与网络的知识终结。<br><br><b>学完之后你应该能:</b>给一个「页面报 500 / 接口偶发超时」的现场,在 10 分钟内判断是前端、网络、网关还是后端的问题,并说清判断依据;能对任意一个被测接口画出从浏览器到数据库的调用链。<br><br><b>学习方式:</b>一半时间在敲命令(curl、ss、tcpdump、mitmproxy),一半时间在画图和归因。看懂一次真实抓包,胜过读十篇文章。"
|
||||
},
|
||||
{
|
||||
"dir": "s0-02-golang",
|
||||
"title": "编程基础:Golang 与工程化",
|
||||
"sub": "语法 · 错误处理 · 接口与并发 · 工程结构",
|
||||
"hours": "建议投入 30–40 小时",
|
||||
"lead": "<b>模块定位:</b>阶段 0 的第 2 个模块,也是整条路线里最不能省的一个。后面的单元测试、接口自动化框架、测试平台后端全部是 Go 代码,这一层没打好,后面只能抄别人的代码改。<br><br><b>学完之后你应该能:</b>独立写出带错误处理、接口依赖注入、超时控制的 Go 程序;读懂一个陌生 Go 服务从 main 到数据库的请求路径;交付一个自己写的测试数据生成与校验 CLI。<br><br><b>学习方式:</b>只读书不动手等于没学。每个知识点都写一个能跑起来的最小程序,最后合成一个 CLI 交付物。"
|
||||
},
|
||||
{
|
||||
"dir": "s0-03-linux-git",
|
||||
"title": "Linux、Shell 与 Git",
|
||||
"sub": "命令行 · 日志 · 脚本 · 版本协作",
|
||||
"hours": "建议投入 20–28 小时",
|
||||
"lead": "<b>模块定位:</b>阶段 0 的第 3 个模块。测试环境出问题时,能救你的不是界面而是命令行:看进程、翻日志、查端口、起停服务、写脚本,以及用 Git 把这一切留下来。<br><br><b>学完之后你应该能:</b>在没有任何监控的情况下定位「服务为什么起不来」;用一条管道从日志里捞出失败请求 TOP10;写出带 <code>set -euo pipefail</code> 与 <code>trap</code> 的可复用脚本;用 <code>git bisect</code> 找到引入缺陷的那次提交。<br><br><b>学习方式:</b>准备一个 Linux 环境(WSL 或虚拟机均可),所有命令都要真的敲一遍,脚本要真的能跑。"
|
||||
},
|
||||
{
|
||||
"dir": "s0-04-database",
|
||||
"title": "数据库与 SQL",
|
||||
"sub": "查询 · 连接 · 校验 · 造数与清理",
|
||||
"hours": "建议投入 20–26 小时",
|
||||
"lead": "<b>模块定位:</b>阶段 0 的第 4 个模块。界面上显示「下单成功」不算成功,数据落对了才算。能自己写 SQL 的测试工程师,定位效率和话语权完全不一样。<br><br><b>学完之后你应该能:</b>用 SQL 独立验证一条业务规则(金额对账、状态流转、无孤儿数据、无重复支付);针对一套订单与支付表结构写出 10 条可重复执行的校验 SQL;造出可追溯、可清理的测试数据。<br><br><b>学习方式:</b>找一个能随便造数的开发库,边学边写;每条校验 SQL 都要能说清「结果应该是几行、出现几行说明什么」。"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"dir": "s0-02-golang",
|
||||
"title": "编程基础:Golang 与工程化",
|
||||
"sub": "语法 · 错误处理 · 接口与并发 · 工程结构",
|
||||
"hours": "建议投入 30–40 小时",
|
||||
"lead": "<b>模块定位:</b>阶段 0 的第 2 个模块,也是整条路线里最不能省的一个。后面的单元测试、接口自动化框架、测试平台后端全部是 Go 代码,这一层没打好,后面只能抄别人的代码改。<br><br><b>学完之后你应该能:</b>独立写出带错误处理、接口依赖注入、超时控制的 Go 程序;读懂一个陌生 Go 服务从 main 到数据库的请求路径;交付一个自己写的测试数据生成与校验 CLI。<br><br><b>学习方式:</b>只读书不动手等于没学。每个知识点都写一个能跑起来的最小程序,最后合成一个 CLI 交付物。"
|
||||
},
|
||||
{
|
||||
"dir": "s0-03-linux-git",
|
||||
"title": "Linux、Shell 与 Git",
|
||||
"sub": "命令行 · 日志 · 脚本 · 版本协作",
|
||||
"hours": "建议投入 20–28 小时",
|
||||
"lead": "<b>模块定位:</b>阶段 0 的第 3 个模块。测试环境出问题时,能救你的不是界面而是命令行:看进程、翻日志、查端口、起停服务、写脚本,以及用 Git 把这一切留下来。<br><br><b>学完之后你应该能:</b>在没有任何监控的情况下定位「服务为什么起不来」;用一条管道从日志里捞出失败请求 TOP10;写出带 <code>set -euo pipefail</code> 与 <code>trap</code> 的可复用脚本;用 <code>git bisect</code> 找到引入缺陷的那次提交。<br><br><b>学习方式:</b>准备一个 Linux 环境(WSL 或虚拟机均可),所有命令都要真的敲一遍,脚本要真的能跑。"
|
||||
},
|
||||
{
|
||||
"dir": "s0-04-database",
|
||||
"title": "数据库与 SQL",
|
||||
"sub": "查询 · 连接 · 校验 · 造数与清理",
|
||||
"hours": "建议投入 20–26 小时",
|
||||
"lead": "<b>模块定位:</b>阶段 0 的第 4 个模块。界面上显示「下单成功」不算成功,数据落对了才算。能自己写 SQL 的测试工程师,定位效率和话语权完全不一样。<br><br><b>学完之后你应该能:</b>用 SQL 独立验证一条业务规则(金额对账、状态流转、无孤儿数据、无重复支付);针对一套订单与支付表结构写出 10 条可重复执行的校验 SQL;造出可追溯、可清理的测试数据。<br><br><b>学习方式:</b>找一个能随便造数的开发库,边学边写;每条校验 SQL 都要能说清「结果应该是几行、出现几行说明什么」。"
|
||||
"id": "s1",
|
||||
"num": "1",
|
||||
"title": "会测",
|
||||
"sub": "测试理论与手工测试基本功",
|
||||
"anchorText": "阶段 1 · 会测",
|
||||
"modules": [
|
||||
{
|
||||
"dir": "s1-01-case-design",
|
||||
"title": "测试理论与用例设计",
|
||||
"sub": "测试的本质 · 需求分析 · 设计方法 · 评审 · 分层与类型",
|
||||
"hours": "建议投入 22–28 小时",
|
||||
"lead": "<b>模块定位:</b>阶段 1 的第 1 个模块,也是「会测」这件事的地基。用例写得出来,后面的接口测试、自动化、测试平台才有东西可跑;用例写不出来,工具学得再多,也只是把乱点变成自动乱点。<br><br><b>学完之后你应该能:</b>拿到一段需求或一个原型,独立拆出测试点,用等价类、边界值、判定表、场景法把它变成别人能直接执行的用例;组织一次评审,并说清每条用例对应的是哪一类风险。<br><br><b>学习方式:</b>别把这一模块当方法论读。拿你手上正在测的那个功能直接写:每学一种设计方法就回到同一个功能上补一批用例,最后合成一份 30 条以上的用例集,并真的找人评一次。"
|
||||
},
|
||||
{
|
||||
"dir": "s1-02-http-api",
|
||||
"title": "HTTP 接口与接口测试基础",
|
||||
"sub": "请求响应 · 鉴权 · 参数 · 工具 · 用例设计 · 抓包改包",
|
||||
"hours": "建议投入 24–30 小时",
|
||||
"lead": "<b>模块定位:</b>阶段 1 的第 2 个模块。界面能点出来的问题只是冰山一角:接口才是业务规则真正落地的地方,也是后面自动化和测试平台要接的那一层。<br><br><b>学完之后你应该能:</b>不看文档也能用 <code>curl</code> 把一次请求完整发出去;能拆开请求与响应,判断 4xx / 5xx 到底该找谁;能处理登录态、构造任意参数,并用抓包改包验证后端是不是真的做了校验;为一个下单接口交出含幂等与越权场景的接口用例集。<br><br><b>学习方式:</b>所有示例都在命令行里自己跑一遍。Postman 可以点,但只有 <code>curl</code> 会告诉你请求到底是什么样子。"
|
||||
},
|
||||
{
|
||||
"dir": "s1-03-web-frontend",
|
||||
"title": "Web 前端基础与调试",
|
||||
"sub": "HTML / CSS / JS · DevTools · 缓存与异步 · 埋点与灰度",
|
||||
"hours": "建议投入 18–24 小时",
|
||||
"lead": "<b>模块定位:</b>阶段 1 的第 3 个模块。前端是缺陷的入口,也是「责任边界」争论最集中的一层。能读 DOM、能看 Network、能在 Sources 里打断点,你就不需要靠猜和转述。<br><br><b>学完之后你应该能:</b>用 DevTools 复现「只在特定条件下出现」的前端缺陷(缓存、异步渲染、iframe);用控制台与请求记录证明问题出在哪一层;看懂埋点与灰度开关导致的「数据缺失」和「功能不生效」。<br><br><b>学习方式:</b>把浏览器开发者工具当成主战场,每看一个现象都要求自己拿到一份可复现的证据(截图 + 请求记录 + 控制台输出)。"
|
||||
},
|
||||
{
|
||||
"dir": "s1-04-defect-process",
|
||||
"title": "缺陷管理与测试流程",
|
||||
"sub": "缺陷生命周期 · 缺陷单 · 分级 · 流程与报告",
|
||||
"hours": "建议投入 16–22 小时",
|
||||
"lead": "<b>模块定位:</b>阶段 1 的第 4 个模块。测试的价值最终要靠「说清楚」交付出去:一条能被开发的缺陷单、一份能让产品经理做决定的测试报告、一次说得清风险的发布评审。<br><br><b>学完之后你应该能:</b>写出不需要二次追问的缺陷单;用证据处理「这不是缺陷」的争议;为一个版本走完从需求评审到上线验证的完整流程,并给出明确的发布建议。<br><br><b>学习方式:</b>拿你最近提交的缺陷单和最近一次的测试记录复盘:哪些被开发打回过?哪些风险是上线后才发现的?从这些真实记录里改流程。"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user