/godot-testing:godot-testingfrom godot-testing
Writes and runs Godot 4 tests with GUT, gdUnit4 or a bare SceneTree runner, picking from what the project has. Covers test layout and naming, doubles and signals, headless runs with exit codes, hangs and timeouts, and a CI job. Use for `test_*.gd`, `addons/gut`, `addons/gdUnit4`, "test this Godot script" or Godot CI.
Ships in godot-testing. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Pick the test framework the project already uses, write tests in its conventions, and run them headless with an exit code CI can gate on. General TDD discipline stays in unit-testing; GDScript language and scene work stay in godot; export builds in godot-export.
Check in this order and use the first match. Do not add a second framework to a project that has one.
| Signal | Framework | Read |
|---|---|---|
addons/gut/ or .gutconfig.json, tests that extends GutTest | GUT | references/gut.md |
addons/gdUnit4/, tests that extends GdUnitTestSuite, [TestSuite] C# classes, gdUnit4.api in the .csproj | gdUnit4 | references/gdunit4.md |
| Neither, and the user does not want an addon | Bare SceneTree runner | Section 4 below |
Read plugin.cfg in the addon folder for the installed version, and config/features in project.godot for the Godot version, before relying on a version-specific API. The references list which addon versions match which Godot versions.
No framework yet and the user wants one: GDScript-only project, choose GUT; C# or mixed project, or heavy scene-input testing, choose gdUnit4. Install from the Asset Library or the release zip into addons/, then enable it in Project Settings > Plugins.
| GUT | gdUnit4 | |
|---|---|---|
| Languages | GDScript | GDScript and C# (C# via gdUnit4Net, dotnet test) |
| Base class | extends GutTest | extends GdUnitTestSuite; C# [TestSuite] class |
| Discovery | Files with the test_ prefix in the configured dirs; methods test_* | Any script extending GdUnitTestSuite; methods test_* |
| Doubles | double(), partial_double(), stub(), spies | mock(), spy(), do_return(), verify() (GDScript only; C# uses Moq or similar) |
| Scenes | add_child_autofree(), wait_* helpers, input sender | auto_free(), scene_runner() with input simulation |
| CLI | addons/gut/gut_cmdln.gd | addons/gdUnit4/runtest.sh (runs bin/GdUnitCmdTool.gd) |
| Exit codes | 0 pass, 1 fail | 0 pass, 100 fail, 101 warnings, 103 headless refused |
| Best for | Pure GDScript projects | C# or mixed projects, UI and input tests |
res://
├── src/ (or scripts/, scenes/)
└── test/
├── unit/ # one test file per class, no scene tree needed
└── integration/ # scenes, autoloads, signals across nodes
test/ is the default for both GUT's suggested setup and gdUnit4's test root. Follow the project if it already uses tests/.test_<thing>.gd, methods func test_<behaviour>(), inner classes grouping tests start with Test.func test_<behaviour>(); its generator names files <thing>_test.gd. C#: <Thing>Test.cs, a [TestSuite] class with [TestCase] methods..gdignore to folders that must not be imported. Do not put tests under addons/.add_child_autofree() / autofree(), gdUnit4 auto_free(). Leaked nodes show up as orphans and can fail runs.watch_signals(obj), gdUnit4 monitor_signals(obj)).wait_for_signal(sig, max_seconds) / wait_until, gdUnit4 await assert_signal(obj).wait_until(ms).is_emitted(...). A bare await obj.sig hangs the run if the signal never fires.assert_almost_eq, gdUnit4 is_equal_approx).Do not test: engine internals (that add_child works, that @export shows in the inspector); private implementation details; pixel output (test the data that drives the visuals); one-line wrappers around built-ins; every imaginable invalid input instead of the documented contract.
For pure logic in a project without a test addon. Run with godot --headless --path . --script res://test/test_runner.gd.
# res://test/test_runner.gd
extends SceneTree
var passed := 0
var failed := 0
func _initialize() -> void:
await run_tests()
print("Results: %d passed, %d failed" % [passed, failed])
quit(1 if failed > 0 else 0) # the exit code is the CI signal
func check_eq(actual: Variant, expected: Variant, label: String) -> void:
if actual == expected:
passed += 1
else:
failed += 1
push_error("FAIL %s: expected %s, got %s" % [label, expected, actual])
func run_tests() -> void:
check_eq(2 + 2, 4, "add")
# Nodes, timers and signals need a processed frame: root is not in the tree yet.
await process_frame
var timer := Timer.new()
timer.one_shot = true
root.add_child(timer)
timer.start(0.1)
await timer.timeout
check_eq(timer.is_stopped(), true, "timer fires once")
timer.queue_free()
$GODOT, else godot, godot4 or godot-mono on PATH; --version must print a version.godot --headless --path . --import. .godot/ is not committed, so without it class_name types fail with Identifier "X" not declared in the current scope and imported assets fail to load.timeout 300 godot --headless ....godot-editor tools), run_headless from the project's godot-mcp skill runs the same commands and returns diagnostics; save open scenes first.- name: Import project
run: godot --headless --path . --import
- name: Run tests
timeout-minutes: 10
run: <framework command from the reference>
Install Godot with a pinned version matching config/features, and keep timeout-minutes as a backstop. gdUnit4 also has an official GitHub Action (see its reference).
assert() hangs a runner. In a debug build a failed assert() inside _initialize() prints SCRIPT ERROR: Assertion failed and stops the function before quit(), so the process never exits. Count failures and call quit(code) yourself.quit(1). push_error() alone does not change the exit code.-d (local debugger) in CI can stop at an interactive debug> prompt on a script error and hang. Leave -d out of CI commands, or redirect the debugger as gdUnit4's runtest.sh does (--remote-debug tcp://127.0.0.1:0).xvfb-run on Linux CI). gdUnit4 refuses headless runs (exit 103) unless you pass --ignoreHeadlessMode.push_error, engine errors). Assert expected ones with assert_push_error / assert_engine_error instead of ignoring them.0, "", false, Vector2.ZERO and so on, not null. Tests that expected null from a double fail after the upgrade. Versions are in references/gut.md.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub adminhead/claude-plugins --plugin godot-testing