godot-testing-debug
Installation
SKILL.md
Testing and debugging (4.7)
Run tests: python scripts/test_run.py [--gd|--cs] [-a res://test/x] [--filter expr] returns {gd: {total, failed, failures: [{test, file, line, msg}]}, cs: {...}}. It imports first, runs headless, and parses the JUnit/console results.
Before tests, compile: ../godot-gdscript/scripts/gd_check.py and ../godot-csharp/scripts/cs_build.py. Smoke-run the game with ../godot-core/scripts/run_godot.py smoke.
GDScript: GdUnit4 (verified 6.2.2 on 4.7.2)
- Install: copy
addons/gdUnit4from the GitHub release (github.com/godot-gdunit-labs/gdUnit4, tag v6.2.x) and enable the plugin. Tests go inres://test/, with names ending in_test.gd. - A suite
extends GdUnitTestSuite. Tests arefunc test_*(). Hooks:before(),after()(per suite),before_test(),after_test(). - Assertions:
assert_int/float/str/bool/vector/array/dict/object(x).is_equal(...),assert_that(x),assert_signal(obj).is_emitted("died")(aftermonitor_signals(obj)),assert_error(func() -> void: ...), andawait assert_func(obj, "is_ready").is_true(). - Memory: wrap created objects in
auto_free(...). The report flags orphan nodes, so treat them as bugs. - Doubles:
mock(Class)+do_return(v).on(m).method(),spy(instance),verify(m, times).method(args),any_int()and friends. - Integration:
var runner := scene_runner("res://player.tscn"), thenrunner.simulate_action_pressed("jump"),await runner.simulate_frames(30),runner.simulate_key_pressed(KEY_SPACE),await runner.await_signal("landed"),runner.invoke("method")andrunner.scene(). - CLI (what
test_run.pycalls):godot --headless --path . -s -d res://addons/gdUnit4/bin/GdUnitCmdTool.gd --ignoreHeadlessMode -c -a res://test. Exit code 0 means pass and 100 means failures. If you launch it yourself, close stdin (< /dev/null): with-d, a runtime error in a test otherwise waits forever at thedebug>prompt (test_run.pyalready does this). Reports are JUnit XML under the-rddirectory.