godot-gdscript-headless-testing
Was er macht
Dieser Skill zeigt, wie du Godot-GDScript-Tests im Terminal ausführst, ohne das Editorfenster zu öffnen. Er ist für Teams gedacht, die automatische Prüfungen ihres Godot-Codes wollen.
Wann du ihn nutzt
- ✓Wenn ein Godot-Projekt Unit-Tests braucht, die ohne geöffneten Editor laufen.
- ✓Wenn du einen CI-Job einrichtest, der fehlschlagen muss, sobald ein GDScript-Test fehlschlägt.
- ✓Wenn ein Godot-Befehl ohne Oberfläche hängt, ein Fenster öffnet oder trotz fehlgeschlagener Tests durchläuft.
Link zum Skill
https://github.com/gamedev-skills/awesome-gamedev-agent-skills/blob/main/skills/godot/godot-gdscript-headless-testing/SKILL.mdKopiere ihn und füge ihn in deine KI ein (Claude, ChatGPT oder Cursor) mit der Bitte, den Anweisungen zu folgen.
So nutzt du ihn
Am einfachsten: Kopiere die Nachricht und füge sie in deine KI ein. Sie liest den Skill und folgt den Anweisungen.
Fertige Nachricht zum Einfügen
Für Claude Code, Codex oder Cursor: Führe den Befehl in deinem Projektordner aus, dann wird der Skill installiert.
Lade die SKILL.md herunter und lege sie in den Skills-Ordner deines Agenten.
Beispielanfrage an deine KI
“Richte Tests für die Logik meines Godot-Spiels ein, die bei jeder Änderung automatisch laufen, ohne dass der Editor geöffnet wird.”
5 neue Skills pro Woche. 1 Minute Lesezeit.
So funktioniert es
Der Skill leitet den Agenten an, Godot im Headless-Modus mit einem Test-Runner-Skript auszuführen, das bei einem Fehler einen Fehlercode zurückgibt, sodass automatisierte Systeme Probleme erkennen.
Technischer Inhalt (originale SKILL.md)
Originaltext des Autors, auf Englisch, direkt von GitHub.
Godot GDScript headless testing (4.x)
Run GDScript tests from the command line, without the editor GUI, and get a real process exit code CI can act on. Targets Godot 4.7 headless CLI.
When to use
- Use when a Godot project has no testing addon installed and needs a fast way to verify GDScript logic (pure functions, resource loading, autoload state) from a terminal or CI pipeline.
- Use when wiring a CI job that must fail the build when a
.gdtest fails. - Use when debugging why a
godot --headlessinvocation hangs, opens a window, or exits 0 despite failing assertions.
When not to use: GDScript syntax or language features themselves →
godot-gdscript; export/build pipeline and platform templates → godot-export
(its own --headless use case, producing a binary, not running tests).
Workflow
- Confirm the binary resolves headless. Godot 4.x ships
--headlessbuilt in (no export template needed); rungodot --headless --versionand confirm it prints a version string, not a GUI window. - On a fresh checkout, import before running tests.
.godot/is normally not committed, so a clean checkout has no import cache:class_nametypes fail to resolve (Identifier "X" not declared in the current scope) and imported assets fail to load (No loader found for resource: res://...). Rungodot --headless --path <project_dir> --importonce first, in CI and locally. - Write the runner as a
SceneTreescript, not aNodescene. ASceneTreescript's_initialize()runs once before any frame — enough for pure-logic tests and no.tscnrequired to launch. - Track pass/fail counts yourself and call
quit(<code>)explicitly. Do not use bareassert()to fail a test. Godot does not turn the process exit code non-zero onpush_error()by itself — the runner must count failures and callquit(1). Worse, a failedassert()inside_initialize()(official/debug build) printsSCRIPT ERROR: Assertion failedand stops execution beforequit()runs, so the process never exits and CI hangs until its own timeout. Use anassert_eq()-style helper that records the failure and keeps going. - Invoke with
godot --headless --path <project_dir> --script res://<runner>.gdand read the process exit code, not just stdout, from the shell or CI step.--scriptaccepts both ares://-relative path and an absolute filesystem path (e.g. a runner outside the project folder); either works. - Redirect stdout and stderr to files when scripting the invocation from a
wrapper shell (PowerShell, some CI runners).
push_error()output goes to stderr and can be dropped or reordered when only stdout is captured live. - Add a step timeout in CI. Even with the
assert()pitfall avoided, anawaitthat never resolves (Pattern #2) hangs the runner forever; atimeout-minuteson the CI step is a backstop CI-side, not a substitute for backing everyawaitwith a timeout node.
Patterns
1. Minimal SceneTree test runner with a real exit code
# res://test_runner.gd — run with:
# godot --headless --path . --script res://test_runner.gd
extends SceneTree
var passed := 0
var failed := 0
func _initialize() -> void:
test_add()
print("Results: %d passed, %d failed" % [passed, failed])
quit(1 if failed > 0 else 0) # non-zero exit fails the CI step
func assert_eq(actual, expected, label: String) -> void:
if actual == expected:
passed += 1
else:
failed += 1
push_error("FAIL %s: expected %s, got %s" % [label, expected, actual])
func test_add() -> void:
assert_eq(2 + 2, 4, "test_add")
Verified against Godot 4.7.2: godot --headless --path . --script res://test_runner.gd prints Results: N passed, M failed to stdout, routes
push_error lines to stderr, and returns process exit code 0 when
failed == 0, 1 otherwise.
2. Testing something that needs a frame, a timer, or a signal
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) # track and report failures here too
func assert_eq(actual, expected, label: String) -> void:
if actual == expected:
passed += 1
else:
failed += 1
push_error("FAIL %s: expected %s, got %s" % [label, expected, actual])
Häufige Fragen
Brauche ich den Godot-Editor, um diese Tests auszuführen?
Nein. Die Tests laufen im Terminal im Headless-Modus, es wird kein Editorfenster benötigt.
Warum schlägt ein frischer Checkout manchmal fehl?
Der Import-Cache wird meist nicht in der Versionskontrolle gespeichert, daher erklärt der Skill, zuerst einen Import-Schritt auszuführen.
Funktioniert das in einer CI-Pipeline?
Ja. Der Runner beendet sich bei einem Fehler mit einem Fehlercode, sodass ein CI-System den Build stoppen kann.
Details
Originalbeschreibung des Autors
Run GDScript test suites from the command line with `godot --headless`, using a SceneTree/MainLoop runner script that exits non-zero on failure so CI can gate merges. Use when a Godot project needs unit tests without opening the editor, when wiring a CI job (GitHub Actions or similar) that must fail the build on a failing `.gd` test, or when a `godot --headless` invocation hangs, opens a window, or exits 0 despite failed assertions.
Beliebtheit
- GitHub-Sterne
- 6.6k
- Platz im Ranking
- #13822
- Lizenz
- Apache-2.0
- Aktualisiert
- 28.10.2026
Kommentare
- …
Weitere Skills aus diesem Repository
router
6.6kHilft deinem Agenten, für eine Anfrage den passenden Spiele-Entwicklungs-Skill zu finden, indem er deine Engine und die Art der Aufgabe erkennt.
ai-behavior-trees-utility-ai
6.6kHilft deinem Agenten, einen Behavior Tree und eine Utility-KI für Gegner und Figuren zu bauen, die Aktionen nach Priorität und Punktwert wählen.
audio-design
6.6kBringt deinem Agenten das Mischen von Spiel-Audio bei: Busse, Lautstärke in Dezibel, Absenkung unter Dialogen, adaptive Musik und Variationen von Soundeffekten.
camera-systems
6.6kHilft deinem Agenten, Spielkameras zu bauen, die sanft folgen, innerhalb des Levels bleiben und sich in 3D um die Figur drehen oder umschauen lassen.
Ähnliche Skills
diffs
394kLässt deinen Agenten einen echten, teilbaren Diff seiner Änderungen als Viewer-Link oder Bilddatei erstellen, statt einer handgeschriebenen Zusammenfassung.
coding-agent
394kHilft deinem Agenten, eine größere Programmieraufgabe als Hintergrund-Worker an Codex, Claude Code oder OpenCode zu übergeben und danach den Fortschritt zu prüfen.
gh-issues
394kHilft deinem Agenten, GitHub-Issues zu finden, die zu bearbeitenden auszuwählen und Pull Requests mit Korrekturen zu öffnen, einschließlich der Nacharbeit an Review-Kommentaren.