s-test

Falkicon 的头像作者 Falkicon

使用 Busted 和 Mechanic 测试框架为 WoW 插件编写并运行单元测试。涵盖测试结构、模拟 WoW API 和覆盖率分析。在添加测试、通过回归测试修复错误或提高覆盖率时使用。触发器:测试、单元测试、覆盖率、Busted、模拟、TDD、沙箱。

📖 中文导读:使用 Busted 和 Mechanic 测试框架为 WoW 插件编写并运行单元测试。涵盖测试结构、模拟 WoW API 和覆盖率分析。在添加测试、通过回归测试修复错误或提高覆盖率时使用。触发器:测试、单元测试、覆盖率、Busted、模拟、TDD、沙箱。 以下正文为该技能的原始 SKILL.md 内容(英文),上方安装命令可直接使用。

name: s-test description: > Write and run unit tests for WoW addons using Busted and the Mechanic test framework. Covers test structure, mocking WoW APIs, and coverage analysis. Use when adding tests, fixing bugs with regression tests, or improving coverage. Triggers: test, unit test, coverage, Busted, mock, TDD, sandbox.

Testing WoW Addons

Expert guidance for testing WoW addons using Sandbox, Desktop, and In-Game methods.

  • c-test - Run unit tests workflow
  • c-review - Full code review (includes test step)

CLI Commands (Use These First)

MANDATORY: Always use CLI commands before manual exploration.

Task Command
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

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

Routing Logic

Request type Load reference
Sandbox, Busted, In-Game guides ../../docs/integration/testing.md
Busted spec patterns references/busted-patterns.md
Mocking WoW APIs references/wow-mocking.md
MechanicLib test registration ../../docs/integration/mechaniclib.md

Quick Reference

  1. Sandbox (Core): Fast feedback for business logic.
  2. Desktop (Integration): Test interactions between modules.
  3. In-Game (Verification): Final check against live APIs.

Example Sandbox Test

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

Running Tests

# Generate stubs once
mech call sandbox.generate

# Run tests frequently
mech call sandbox.test -i '{"addon": "MyAddon"}'