Token导航 LogoToken导航TokenDH.com
开发需要联网github未标认证来源可访问许可证需确认审计通过

godot-testing-patterns戈多测试模式

Agent Skill

用于辅助测试设计、自动化测试、用例整理和回归验证。它适合让 Agent 编写单元测试、端到端测试、测试计划或根据失败日志定位问题。使用时需要确认项目测试框架、运行命令和夹具数据,避免为了通过测试而改坏真实逻辑;涉及浏览器或外部服务时,应区分本地模拟、测试环境和生产环境。

总安装

2,893

周安装

123

GitHub Stars

138

下载量

1,014
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:godot-testing-patterns(戈多测试模式)
来源仓库:https://github.com/thedivergentai/gd-agentic-skills
仓库路径:skills/godot-testing-patterns
安装命令:
npx skills add https://github.com/thedivergentai/gd-agentic-skills --skill godot-testing-patterns
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/thedivergentai/gd-agentic-skills --skill godot-testing-patterns

简介

用于辅助测试设计、自动化测试、用例整理和回归验证。

  • 适合编写单元测试、端到端测试或根据日志定位问题。
  • 通过 npx skills add 命令从指定 GitHub 仓库安装并使用。
  • 使用时需确认测试框架与运行命令,避免为通过而破坏逻辑。
  • godot-testing-patterns 属于开发类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Testing Patterns

GUT framework, assertion patterns, mocking, and async testing define automated validation.

Available Scripts

basic_unit_test.gd

Minimal GdUnit4 test structure for verifying simple logic and arithmetic.

signal_emission_test.gd

Expert pattern for monitoring and verifying signal emissions in decoupled architectures.

mock_dependency_test.gd

Using Mocks and Doubles to isolate test subjects from external services or databases.

scene_integration_test.gd

Full scene lifecycle testing, verifying node interactions after instantiation.

performance_benchmark_runner.gd

High-precision execution time measurement using microsecond-scale timers.

memory_leak_detector.gd

Automated orphan node detection to catch memory leaks during long-running tests.

parameter_fuzz_tester.gd

Stress testing systems with randomized data ranges to catch edge-case crashes.

wait_for_frame_test.gd

Advanced async testing for logic that spans multiple frames or game ticks.

physics_collision_test.gd

Automated verification of physics layer interactions and collision resolution.

test_data_factory.gd

Centralized data generation patterns for clean, schemas-compliant test objects.

NEVER Do in Testing

  • NEVER test implementation detailsassert_eq(player._internal_state, 5)? Private variables = brittle tests. Test PUBLIC behavior, not internals [20].
  • NEVER share state between tests — Test 1 modifies global variable, test 2 assumes clean state? Flaky tests. Use before_each() for fresh setup [21].
  • NEVER use sleep() for timingawait get_tree().create_timer(1.0).timeout in tests? Slow + unreliable. Use GUT's wait_seconds() OR manual frame stepping [22].
  • NEVER skip cleanup in after_each() — Test spawns 100 nodes, doesn't free? Memory leak + slow test suite. ALWAYS free nodes in after_each() [23].
  • NEVER test randomness without seedingrandi() in test = non-deterministic failure. Use seed(12345) for repeatable tests [24].
  • NEVER forget to watch signalsassert_signal_emitted(obj, "died") without watch_signals? Fails silently. MUST call watch_signals(obj) first [25].
  • NEVER perform tests without an explicit "Definition of Done" — Vague tests like assert_true(true) provide zero value. Every test should verify a specific requirement.
  • NEVER rely on editor-only features for CI/CD tests — Headless environments lack Viewports. Ensure tests are headless-compatible.
  • NEVER ignore the cost of "Integration Tests" — Testing a whole level is slow. Favor narrow Unit Tests for logic and small Scene Tests for interaction.
  • NEVER hardcode file paths in tests — Use Path constants or project-relative strings. If a resource directory moves, your suite shouldn't break.
  • NEVER test third-party plugins — Trust the library; test YOUR integration of it.

Installation

  1. Download from AssetLib: "GUT - Godot Unit Test"
  2. Enable in Project Settings → Plugins
  3. Create res://test/ directory

Basic Test

# test/test_player.gd
extends GutTest

var player: CharacterBody2D

func before_each() -> void:
    player = preload("res://entities/player/player.tscn").instantiate()
    add_child(player)

func after_each() -> void:
    player.queue_free()

func test_initial_health() -> void:
    assert_eq(player.health, 100, "Player should start with 100 health")

func test_take_damage() -> void:
    player.take_damage(25)
    assert_eq(player.health, 75, "Health should be 75 after 25 damage")

func test_cannot_have_negative_health() -> void:
    player.take_damage(200)
    assert_gte(player.health, 0, "Health should not go below 0")

Running Tests

# Via GUT panel in editor
# Or command line:
# godot --headless -s addons/gut/gut_cmdln.gd

Assertion Patterns

# Equality
assert_eq(actual, expected, "message")
assert_ne(actual, not_expected, "message")

# Comparison
assert_gt(value, min_value, "should be greater")
assert_lt(value, max_value, "should be less")
assert_gte(value, min_value, "should be >= min")
assert_lte(value, max_value, "should be <= max")

# Boolean
assert_true(condition, "should be true")
assert_false(condition, "should be false")

# Null
assert_not_null(object, "should exist")
assert_null(object, "should be null")

# Arrays
assert_has(array, element, "should contain element")
assert_does_not_have(array, element, "should not contain")

# Signals
watch_signals(object)
assert_signal_emitted(object, "signal_name")

Testing Signals

func test_death_signal() -> void:
    watch_signals(player)

    player.take_damage(100)

    assert_signal_emitted(player, "died")
    assert_signal_emitted_with_parameters(player, "died", [player])

Testing Async

func test_delayed_action() -> void:
    player.start_ability()

    # Wait for timer
    await wait_seconds(1.0)

    assert_true(player.ability_active, "Ability should be active after delay")

Mock/Stub Patterns

# Double (mock) pattern
func test_with_mock() -> void:
    var mock_enemy := double(Enemy).new()
    stub(mock_enemy, "get_damage").to_return(50)

    player.collide_with(mock_enemy)

    assert_eq(player.health, 50, "Should take mocked damage")

Integration Testing

# test/test_combat_system.gd
extends GutTest

func test_player_kills_enemy() -> void:
    var level := preload("res://levels/test_arena.tscn").instantiate()
    add_child(level)

    var player := level.get_node("Player")
    var enemy := level.get_node("Enemy")

    # Simulate combat
    for i in range(5):
        player.attack(enemy)
        await wait_frames(1)

    assert_true(enemy.is_dead, "Enemy should be dead")
    assert_gt(player.score, 0, "Player should have score")

    level.queue_free()

Manual Testing Checklist

## Gameplay
- [ ] Player can move in all directions
- [ ] Jump height feels right
- [ ] Enemies respond to player
- [ ] Damage numbers are correct

## UI
- [ ] All buttons work
- [ ] Text is readable
- [ ] Responsive on different resolutions

## Audio
- [ ] Music plays
- [ ] SFX trigger correctly
- [ ] Volume levels balanced

## Performance
- [ ] Maintains 60 FPS
- [ ] No stuttering
- [ ] Memory stable

Validation Helpers

# validation.gd (for runtime checks)
class_name Validation

static func assert_valid_health(health: int) -> void:
    assert(health >= 0 and health <= 100, "Invalid health: %d" % health)

static func assert_valid_position(pos: Vector2, bounds: Rect2) -> void:
    assert(bounds.has_point(pos), "Position out of bounds: %s" % pos)

Test Organization

test/
├── unit/
│   ├── test_player.gd
│   ├── test_enemy.gd
│   └── test_inventory.gd
├── integration/
│   ├── test_combat.gd
│   └── test_save_load.gd
└── fixtures/
    ├── test_level.tscn
    └── mock_data.tres

Best Practices

1. Test Edge Cases

func test_edge_cases() -> void:
    player.take_damage(0)  # Zero damage
    assert_eq(player.health, 100)

    player.take_damage(-10)  # Negative (heal?)
    assert_eq(player.health, 100)  # Should not change

2. Isolate Tests

# Each test should be independent
func before_each() -> void:
    # Fresh setup for each test
    player = create_fresh_player()

3. Test Critical Paths First

Priority:
1. Core gameplay (movement, combat)
2. Save/load system
3. Level transitions
4. UI interactions

Reference

Related

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

34.67%
按下载量换算352

Claude

30.6%
按下载量换算310

Cursor

19.1%
按下载量换算194

Gemini CLI

9.98%
按下载量换算101

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills