Files
mindfulness/spec_kit/Text Wrap/modules/golden-tests/spec.md
2026-02-10 11:39:33 +08:00

1.7 KiB
Raw Blame History

golden-tests子模块规范

子模块名称

golden-testsGolden Cases 与性质测试)

目标描述

建立可持续的回归体系,保证换行算法满足:

  • 同输入同输出(确定性)
  • 跨端一致(在固定测量/宽度 profile 下)
  • 规则变更可控(通过 configVersion 回溯)

本模块产出的是测试数据与测试规则,不产出业务功能。

输入/输出定义

输入

  • Golden Case 集合(建议 JSON/TS fixture
    • text
    • lang
    • context
    • availableWidth
    • maxLines
    • fontSpec?APP
    • constraints?
    • overflowMode?
    • configVersion

输出

  • 对每个 case 的期望输出:
    • expected.lines: string[]
    • expected.wrappedText: string
    • 可选:expected.meta.breaksexpected.meta.fallback_type/overflow_type/reason

并定义性质测试property tests

  • 确定性:同输入多次调用输出一致
  • 近似单调性availableWidth 变小不会让任一行变得更宽(在同测量模式下)
  • maxLines 不变差maxLines 增加时至少不从可解变 overflow

验收标准(可验证)

  • 覆盖度
    • 每种语言至少 20 个样例:短/长、含标点/无标点、含 emoji、含 protectedPhrases、含 shift/accum/self、极窄宽度
  • 固定口径
    • 测量可控APP 用稳定的测量 mock或固定字体与平台WIDGET 用固定 width profile
  • CI 可运行:在自动化环境可一键跑完(不依赖人工操作)

依赖与关联

  • 依赖core-contractsearch-engine-*scoring-tiebreakoverflow-fallback
  • 被依赖integration(接入后验收也可引用 Golden