s-test

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Testing WoW Addons

WoW插件测试

Expert guidance for testing WoW addons using Sandbox, Desktop, and In-Game methods.
本指南提供使用Sandbox、桌面端和游戏内方法测试WoW插件的专业指导。

Related Commands

相关命令

  • c-test - Run unit tests workflow
  • c-review - Full code review (includes test step)
  • c-test - 运行单元测试工作流
  • c-review - 完整代码评审(包含测试环节)

CLI Commands (Use These First)

CLI命令(优先使用)

MANDATORY: Always use CLI commands before manual exploration.
TaskCommand
Generate Stubs
mech call sandbox.generate
Run Sandbox Tests
mech call sandbox.test -i '{"addon": "MyAddon"}'
Run Busted Tests
mech call addon.test -i '{"addon": "MyAddon"}'
Test Coverage
mech call addon.test -i '{"addon": "MyAddon", "coverage": true}'
Sandbox Status
mech call sandbox.status
强制要求:在手动操作前,请始终优先使用CLI命令。
任务命令
生成桩代码
mech call sandbox.generate
运行Sandbox测试
mech call sandbox.test -i '{"addon": "MyAddon"}'
运行Busted测试
mech call addon.test -i '{"addon": "MyAddon"}'
测试覆盖率
mech call addon.test -i '{"addon": "MyAddon", "coverage": true}'
Sandbox状态
mech call sandbox.status

Capabilities

核心能力

  1. Sandbox Testing — Fast, offline tests using generated WoW API stubs
  2. Desktop Testing (Busted) — Integration tests with custom mocks
  3. In-Game Testing — Runtime verification via MechanicLib registration
  4. Coverage Analysis — Identify untested code paths
  1. Sandbox测试 — 基于生成的WoW API桩代码进行快速离线测试
  2. 桌面端测试(Busted) — 配合自定义模拟的集成测试
  3. 游戏内测试 — 通过MechanicLib注册实现运行时验证
  4. 覆盖率分析 — 识别未被测试的代码路径

Routing Logic

路由逻辑

Request typeLoad reference
Sandbox, Busted, In-Game guides../../docs/integration/testing.md
Busted spec patternsreferences/busted-patterns.md
Mocking WoW APIsreferences/wow-mocking.md
MechanicLib test registration../../docs/integration/mechaniclib.md
请求类型参考文档
Sandbox、Busted、游戏内测试指南../../docs/integration/testing.md
Busted测试用例模式references/busted-patterns.md
模拟WoW APIreferences/wow-mocking.md
MechanicLib测试注册../../docs/integration/mechaniclib.md

Quick Reference

快速参考

Recommended Workflow

推荐工作流

  1. Sandbox (Core): Fast feedback for business logic.
  2. Desktop (Integration): Test interactions between modules.
  3. In-Game (Verification): Final check against live APIs.
  1. Sandbox(核心):为业务逻辑提供快速反馈。
  2. 桌面端(集成):测试模块间的交互逻辑。
  3. 游戏内(验证):基于真实API进行最终校验。

Example Sandbox Test

Sandbox测试示例

lua
describe("MyAddon Core", function()
    it("calculates values correctly", function()
        local result = Core.Calculate(10, 20)
        assert.equals(30, result)
    end)
end)
lua
describe("MyAddon Core", function()
    it("calculates values correctly", function()
        local result = Core.Calculate(10, 20)
        assert.equals(30, result)
    end)
end)

Running Tests

运行测试

bash
undefined
bash
undefined

Generate stubs once

一次性生成桩代码

mech call sandbox.generate
mech call sandbox.generate

Run tests frequently

频繁运行测试

mech call sandbox.test -i '{"addon": "MyAddon"}'
undefined
mech call sandbox.test -i '{"addon": "MyAddon"}'
undefined