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/gdUnit4 from the GitHub release (github.com/godot-gdunit-labs/gdUnit4, tag v6.2.x) and enable the plugin. Tests go in res://test/, with names ending in _test.gd.
  • A suite extends GdUnitTestSuite. Tests are func 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") (after monitor_signals(obj)), assert_error(func() -> void: ...), and await 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"), then runner.simulate_action_pressed("jump"), await runner.simulate_frames(30), runner.simulate_key_pressed(KEY_SPACE), await runner.await_signal("landed"), runner.invoke("method") and runner.scene().
  • CLI (what test_run.py calls): 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 the debug> prompt (test_run.py already does this). Reports are JUnit XML under the -rd directory.
Installs
13
GitHub Stars
54
First Seen
9 days ago