Skip to content
Skill

zinc-unittest

by Crainax

AI Summary

Provides a standardized workflow for creating and maintaining unit tests for Jass modules in War3Lib using Zinc, covering file structure, test generation, assertion patterns, and validation. Essential for developers building or refactoring Jass libraries who need reproducible, maintainable test suites.

Install

Copy this and paste it into Claude Code, Cursor, or any AI assistant:

I want to install the "zinc-unittest" skill in my project.

Please run this command in my terminal:
# Install skill into the correct directory (5 files)
mkdir -p .claude/skills/zinc-unittest && curl --retry 3 --retry-delay 2 --retry-all-errors -o .claude/skills/zinc-unittest/SKILL.md "https://raw.githubusercontent.com/Crainax/War3Lib/master/.codex/skills/zinc-unittest/SKILL.md" && mkdir -p .claude/skills/zinc-unittest/references && curl --retry 3 --retry-delay 2 --retry-all-errors -o .claude/skills/zinc-unittest/references/assert-trace-pattern.md "https://raw.githubusercontent.com/Crainax/War3Lib/master/.codex/skills/zinc-unittest/references/assert-trace-pattern.md" && mkdir -p .claude/skills/zinc-unittest/references && curl --retry 3 --retry-delay 2 --retry-all-errors -o .claude/skills/zinc-unittest/references/examples.md "https://raw.githubusercontent.com/Crainax/War3Lib/master/.codex/skills/zinc-unittest/references/examples.md" && mkdir -p .claude/skills/zinc-unittest/references && curl --retry 3 --retry-delay 2 --retry-all-errors -o .claude/skills/zinc-unittest/references/ut-file-layout.md "https://raw.githubusercontent.com/Crainax/War3Lib/master/.codex/skills/zinc-unittest/references/ut-file-layout.md" && mkdir -p .claude/skills/zinc-unittest/scripts && curl --retry 3 --retry-delay 2 --retry-all-errors -o .claude/skills/zinc-unittest/scripts/create_ut.sh "https://raw.githubusercontent.com/Crainax/War3Lib/master/.codex/skills/zinc-unittest/scripts/create_ut.sh"

Then restart Claude Code (or reload the window in Cursor) so the skill is picked up.

Description

War3Lib 的 Zinc 单元测试流程规范(.j + .cfg + _Test.j + 可选 w3a/w3u/w3i):使用 TaskCreateUT.lua 生成测试壳、维护 cfg 注入与 chain 依赖、使用 UnitTestFramwork.assert 断言与 Trace 日志输出。用于创建/重构 Jass 模块单测时。

1. 建立三件套文件

• 以目标模块 Xxx.j 为中心,确认同目录存在:Xxx.cfg、Xxx_Test.j。 • Xxx.cfg 不存在时创建,并补齐:公开 API 关键词 + [chain] 基础依赖。 • 需要物编辅助测试时,按需创建同名扩展文件:Xxx.w3a(技能)、Xxx.w3u(单位)、Xxx.w3i(物品)。 说明:cfg 前半段用于外部 dependency 注入关键词;[chain] 是该库底层依赖,用于递归注入。

2. 生成或刷新 `_Test.j`(必须走任务脚本)

优先复用项目脚本,不手写测试壳。 • 运行:bash .codex/skills/zinc-unittest/scripts/create_ut.sh <Xxx.j>。 • 该流程会调用 Lua/tasks/TaskCreateUT.lua,并使用模板 Jass/template/UTTemplate.j。 • 已存在 _Test.j 时默认不覆盖,仅更新 Jass/config/UnitTest.h 的 include 到当前测试文件。 如果脚本不可用,再手动按 UTTemplate.j 结构补齐占位符:{UnitTest}、LibraryName、#include。

3. 编写测试逻辑(参考 UnitUtils 风格)

• 在 library UTXxx requires Xxx,... 中按功能拆分 Test_* 私有函数。 • 使用 UnitTestAutoTimer 安排自动测试,避免初始化竞争。 • 聊天命令入口走 s1..s10 或 -参数,复用模板函数 TTestUTXxx* / TTestActUTXxx1。 • 断言优先使用 UnitTestFramwork.assert:Boolean/Integer/Real/String。 • 需要输出到日志时优先用 Trace(...)(YDLua),不要依赖仅本地可见的原生提示。

4. 宏保护与命名

• 测试专用注册与入口放在测试文件中;若写在业务库,必须加:#if (CURRENT_BUILD_VERSION != VERSION_RELEASE)。 • 不使用 _ 开头标识符。 • 用模块名前缀组织测试名与提示文案,保证日志可检索。

Discussion

0/2000
Loading comments...

Health Signals

MaintenanceCommitted 1mo ago
Active
AdoptionUnder 100 stars
8 ★ · Niche
DocsREADME + description
Well-documented

GitHub Signals

Stars8
Forks3
Issues0
Updated1mo ago
View on GitHub
Apache-2.0 License

My Fox Den

Community Rating

Sign in to rate this booster

Works With

Claude Code