| name | godot-testing-patterns |
| description | Expert testing decision trees for GdUnit4: unit vs scene vs CI gates, headless runners, snapshots, and mock networks. Use when choosing test layers, wiring CI, or validating signals/physics without beginner assert catalogs. Keywords: GdUnit4, GdUnitTestSuite, headless CI, snapshot test, mock network, scene integration test, TDD. |
Godot 4.7 Baseline
- Expert patterns in this skill target Godot 4.7+ (stable, 2026-06-18).
- Consult the Godot 4.7 migration guide when upgrading projects from 4.6.
- NEVER assume 4.6 defaults (stretch mode, audio area_mask, RichTextLabel percent flags) without checking 4.7 migration notes.
Testing Patterns (GdUnit4)
Framework: GdUnit4 only (extends GdUnitTestSuite). Do not mix GUT GutTest / watch_signals APIs in new tests.
Decision Tree → Scripts
Do NOT Load assert-catalog tutorials or manual gameplay checklists into context — pick a row, read the script, implement.
MANDATORY Triggers
- CI /
--headless: always read headless_test_runner.gd first (OS.exit_code, GdUnit4 CLI: godot --headless -s addons/gdUnit4/bin/GdUnitCmdTool.gd -a res://test).
- State or visual golden files: read snapshot_tester.gd before writing JSON/image goldens. Approve workflow: first run saves reference; intentional UI change → delete or overwrite
res://tests/snapshots/<name>.png, re-run to regenerate, commit new golden; never hand-edit PNG bytes.
- Any RPC / MultiplayerSynchronizer test: read mock_network_provider.gd before standing up real peers.
Available Scripts
Minimal GdUnit4 (GdUnitTestSuite) structure for pure logic.
Signal emission monitoring for decoupled architectures.
Mocks/doubles to isolate external services.
Scene lifecycle + node interaction fixtures.
CI headless orchestration and exit codes.
Dictionary/UI golden snapshot comparison.
Loopback / offline multiplayer peer for RPC tests.
Microsecond timers + Performance monitor gates.
Orphan node detection across long suites.
Randomized ranges for edge crashes.
Frame/physics-step async verification.
Schema-compliant fixture builders.
NEVER Do in Testing (GdUnit4)
- NEVER test private implementation details — Assert public behavior only.
- NEVER share mutable state between tests — Fresh setup per test (
before_test / equivalent).
- NEVER use wall-clock
sleep / blind timers — Prefer frame steppers from wait_for_frame patterns.
- NEVER skip cleanup — Free instantiated nodes after each test.
- NEVER test randomness without seeding.
- NEVER assert signals without the GdUnit signal assert/monitor helpers from signal_emission_test.gd.
- NEVER mix GUT and GdUnit4 APIs in one suite.
- NEVER rely on editor-only features for CI — Headless-compatible tests only.
- NEVER default to full-level integration tests — Prefer unit + small scene tests; escalate only when the decision tree says so.
- NEVER hardcode brittle absolute file paths in fixtures.
- NEVER test third-party plugin internals — Test your integration only.
Expert Gates (short)
- Snapshot: serialize → compare golden (snapshot_tester.gd); regenerate reference PNG on approved visual changes.
- CI:
--headless + OS.exit_code non-zero on failure (headless_test_runner.gd).
- Network: mock peer before real ENet (
mock_network_provider.gd).
- Perf:
Performance monitors / draw-call caps in benchmark runner.
Deep recipes (on demand)
LLM-ignorance rule: if a general agent would not know it before reading, it lives here or in scripts/ — never delete, only move.
Reference
Progressive disclosure: open Official Documentation links only when researching a specific API; load Related Skills when routing to a peer domain — do not preload the whole lattice.
Official Documentation
Related Skills
Prerequisites
Complements
Downstream / consumers
Master
- godot-master — library router and mirrored module entry for cross-skill discovery.