热门角色不仅是灵感来源,更是你的效率助手。通过精挑细选的角色提示词,你可以快速生成高质量内容、提升创作灵感,并找到最契合你需求的解决方案。让创作更轻松,让价值更直接!
我们根据不同用户需求,持续更新角色库,让你总能找到合适的灵感入口。
本提示词专为开发者和质量保证工程师设计,能够根据函数名称、参数及预期行为自动生成结构化、可复用的后端代码测试用例。通过智能分析代码逻辑和业务场景,确保测试覆盖全面性,显著提升测试效率并降低人工编写成本。支持多种测试类型和优先级设置,适用于单元测试、集成测试等多种测试场景,帮助团队建立高质量的代码测试体系。
// __tests__/releaseNotes.system.test.js
const { composeReleaseNotes } = require('../src/composeReleaseNotes');
const baseInput = () => ({
commits_text: 'feat: 支持离线草稿保存; fix: 登录偶发404; perf: 列表渲染耗时降至180ms; chore: 升级依赖',
version: 'v2.3.0',
audience: '终端用户',
language: 'zh-CN',
sections: ['新增', '修复', '性能'],
include_breaking_changes: false,
summary_length: 120,
constraints: { style: '用简洁动词开头,避免术语堆砌' }
});
describe('composeReleaseNotes - 系统测试', () => {
test('P0-01 标准输入生成结构化发布说明', () => {
const input = baseInput();
const out = composeReleaseNotes(input);
expect(out).toBeDefined();
expect(out.version).toBe('v2.3.0');
expect(out.audience).toBe('终端用户');
expect(out.language).toBe('zh-CN');
expect(typeof out.summary).toBe('string');
expect(out.summary.length).toBeLessThanOrEqual(input.summary_length);
expect(Array.isArray(out.sections)).toBe(true);
const titles = out.sections.map(s => s.title);
expect(titles).toEqual(input.sections);
const findItems = title => out.sections.find(s => s.title === title)?.items || [];
expect(findItems('新增')).toContain('支持离线草稿保存');
expect(findItems('修复')).toContain('登录偶发404');
expect(findItems('性能')).toContain('列表渲染耗时降至180ms');
// chore不应进入已定义分区
expect(findItems('新增')).not.toContain('升级依赖');
expect(findItems('修复')).not.toContain('升级依赖');
expect(findItems('性能')).not.toContain('升级依赖');
// 不包含breaking changes
expect(out.breaking_changes ?? []).toHaveLength(0);
});
test('P0-02 重大变更存在但不包含', () => {
const input = {
...baseInput(),
commits_text: 'feat!: 重构认证流程; BREAKING CHANGE: 令牌格式变更; fix: 修复刷新令牌异常'
};
input.include_breaking_changes = false;
const out = composeReleaseNotes(input);
const itemsAll = out.sections.flatMap(s => s.items);
expect(itemsAll.join(' ')).not.toMatch(/重大变更|BREAKING/i);
expect(out.breaking_changes ?? []).toHaveLength(0);
});
test('P0-03 重大变更包含输出', () => {
const input = {
...baseInput(),
commits_text: 'feat!: 重构认证流程; BREAKING CHANGE: 令牌格式变更; perf: 降低CPU占用',
include_breaking_changes: true
};
const out = composeReleaseNotes(input);
expect(Array.isArray(out.breaking_changes)).toBe(true);
const bc = out.breaking_changes.join(' ');
expect(bc).toMatch(/重构认证流程|令牌格式变更/);
expect(out.summary.length).toBeLessThanOrEqual(input.summary_length);
});
test('P0-04 摘要长度限制生效', () => {
const input = {
...baseInput(),
commits_text: 'feat: 新增A; feat: 新增B; fix: 修复C; perf: 优化D; feat: 新增E; fix: 修复F'
};
const out = composeReleaseNotes(input);
expect(out.summary).toBeTruthy();
expect(out.summary.length).toBeLessThanOrEqual(input.summary_length);
});
test('P0-05 非法audience报错', () => {
const input = { ...baseInput(), audience: '市场' };
expect(() => composeReleaseNotes(input)).toThrow();
});
test('P0-06 sections为空报错', () => {
const input = { ...baseInput(), sections: [] };
expect(() => composeReleaseNotes(input)).toThrow();
});
test('P1-07 未配置分区的提交类型应忽略', () => {
const input = {
...baseInput(),
commits_text: 'chore: 升级依赖; docs: 完善使用文档; feat: 新增导出功能; fix: 修复空指针'
};
const out = composeReleaseNotes(input);
const all = out.sections.flatMap(s => s.items).join(' ');
expect(all).toMatch(/新增导出功能/);
expect(all).toMatch(/修复空指针/);
expect(all).not.toMatch(/升级依赖|使用文档/);
});
test('P1-08 分隔符混合解析', () => {
const input = {
...baseInput(),
commits_text: 'feat: 新增批量导入;fix: 修复搜索异常\nperf: 降低内存使用; chore: 清理脚本'
};
const out = composeReleaseNotes(input);
const findItems = t => out.sections.find(s => s.title === t)?.items || [];
expect(findItems('新增')).toContain('新增批量导入');
expect(findItems('修复')).toContain('修复搜索异常');
expect(findItems('性能')).toContain('降低内存使用');
// chore忽略
expect(findItems('新增')).not.toContain('清理脚本');
});
test('P1-09 受众与语言元信息一致', () => {
const input = baseInput();
const out = composeReleaseNotes(input);
expect(out.audience).toBe(input.audience);
expect(out.language).toBe(input.language);
});
test('P2-10 摘要极短边界', () => {
const input = { ...baseInput(), summary_length: 1 };
const out = composeReleaseNotes(input);
expect(out.summary.length).toBeLessThanOrEqual(1);
expect(out.sections.length).toBeGreaterThan(0);
});
test('P2-11 大规模提交', () => {
const feats = Array.from({ length: 80 }, (_, i) => `feat: 新增功能${i+1}`).join('; ');
const fixes = Array.from({ length: 80 }, (_, i) => `fix: 修复问题${i+1}`).join('; ');
const perfs = Array.from({ length: 40 }, (_, i) => `perf: 优化性能点${i+1}`).join('; ');
const input = {
...baseInput(),
commits_text: `${feats}; ${fixes}; ${perfs}`,
include_breaking_changes: false
};
const start = Date.now();
const out = composeReleaseNotes(input);
const duration = Date.now() - start;
expect(out.summary.length).toBeLessThanOrEqual(input.summary_length);
expect(out.sections.find(s => s.title === '新增')?.items.length || 0).toBeGreaterThan(70);
expect(out.sections.find(s => s.title === '修复')?.items.length || 0).toBeGreaterThan(70);
expect(out.sections.find(s => s.title === '性能')?.items.length || 0).toBeGreaterThan(30);
expect(duration).toBeLessThan(500);
});
});
将函数名称、参数与期望行为快速转化为完整、可复用的后端测试用例套件;在几分钟内覆盖正常流程、边界与异常场景,并自动给予优先级与执行建议;显著降低人工编写成本与遗漏风险,为单元、集成、回归等测试场景提供标准化输出,帮助团队提升发布速度与质量稳定,激发试用兴趣并清晰展示进阶版本的付费价值。
新功能提交前,一键生成基础与边界测试,用最短时间验证核心逻辑,提升重构与合并的安全性。
将需求与函数说明快速转成结构化用例,按风险设优先级,覆盖异常路径,减少手写与沟通成本。
为团队统一测试规范,查看覆盖与风险综述,决定补测计划与资源投入,持续提升质量指标。
将模板生成的提示词复制粘贴到您常用的 Chat 应用(如 ChatGPT、Claude 等),即可直接对话使用,无需额外开发。适合个人快速体验和轻量使用场景。
把提示词模板转化为 API,您的程序可任意修改模板参数,通过接口直接调用,轻松实现自动化与批量处理。适合开发者集成与业务系统嵌入。
在 MCP client 中配置对应的 server 地址,让您的 AI 应用自动调用提示词模板。适合高级用户和团队协作,让提示词在不同 AI 工具间无缝衔接。
免费获取高级提示词-优惠即将到期