# Gdunit4 Test Writer

> Write gdUnit4 test code with type-specific assertions, signal testing, and scene runner support. Use when creating or updating tests for GDScript files. Use when this capability is needed.

- Skill: `tomevault-io/gdunit4-test-writer` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/gdunit4-test-writer`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/gdunit4-test-writer/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/gdunit4-test-writer

---


# gdUnit4 Test Writer

Write gdUnit4 test code for GDScript files with proper assertions and test structure.

## Workflow

1. **Analyze target file** - Read the GDScript file to understand what needs testing
2. **Check gdUnit4 docs** - Use Context7 (`/websites/godot-gdunit-labs_github_io_gdunit4`) if needed
3. **Select assertions** - Use type-specific assertions (see [references/assertions.md])
4. **Create test file** - Place in `res://tests/` directory with `test_*.gd` naming (e.g., `test_player.gd`)

## Quick Reference

### Test File Template

```gdscript
extends GdUnitTestSuite

func test_example() -> void:
    assert_int(1).is_equal(1)
```

### Common Assertions

- **int**: `assert_int(value).is_equal(10)`
- **float**: `assert_float(value).is_equal_approx(3.14, 0.01)`
- **String**: `assert_str(text).contains("hello")`
- **Array**: `assert_array(items).has_size(5)`
- **Object**: `assert_object(node).is_not_null()`
- **Signal**: `await assert_signal(emitter).is_emitted("signal_name")`

### Memory Management

```gdscript
func test_with_node() -> void:
    var node: Node = auto_free(Node.new())  # Auto-freed after test
    assert_object(node).is_not_null()
```

## References

- [references/assertions.md](assertions.md) - Complete assertion reference
- [references/test-structure.md](test-structure.md)- Test lifecycle and structure
- [references/signals.md](signals.md) - Signal testing guide
- [references/scene-runner.md](scene-runner.md) - Scene runner for integration tests

## Context7 Library ID

For detailed gdUnit4 documentation:
- Library ID: `/websites/godot-gdunit-labs_github_io_gdunit4`

---
> Converted and distributed by [TomeVault](https://tomevault.io/claim/minami110) — claim your Tome and manage your conversions.
<!-- tomevault:4.0:skill_md:2026-04-13 -->

