Gum gum-unit-tests
Reference guide for writing unit tests in the Gum repository. Load this when writing or modifying tests in Gum.ProjectServices.Tests, Gum.Cli.Tests, or any other Gum test project.
install
source · Clone the upstream repo
git clone https://github.com/vchelaru/Gum
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/vchelaru/Gum "$T" && mkdir -p ~/.claude/skills && cp -r "$T/.claude/skills/gum-unit-tests" ~/.claude/skills/vchelaru-gum-gum-unit-tests && rm -rf "$T"
manifest:
.claude/skills/gum-unit-tests/SKILL.mdsource content
Gum Unit Test Reference
Test Projects
| Project | Location | What it tests |
|---|---|---|
| | Default project for new tests. MonoGame runtime, Forms controls, rendering, localization, data types — anything not specific to V2/V3 visuals or integration |
| | Headless services: error checking, codegen, font generation, project loading |
| | CLI command exit codes and output |
| | Tests specific to V2 default visuals |
| | Tests specific to V3 default visuals |
| | Requires a real : content loading, renderer teardown, full lifecycle |
When in doubt, put tests in
. Only use V2/V3 projects for tests that exercise visual-version-specific behavior.MonoGameGum.Tests/
Key Rules
- Always use Shouldly — never xUnit
. Alphabetize test methods within a class.Assert - Disable parallel execution in every test project (
) — Gum uses global singletons.[assembly: CollectionBehavior(DisableTestParallelization = true)] - Use named parameters for boolean literals.
Headless Tests (ProjectServices, MonoGameGum.Tests.V2)
Read
BaseTestClass before adding setup — it handles singleton init, a ready-made GumProjectSave, and Dispose cleanup. Don't repeat that in subclasses.
Every
StateSave must have ParentContainer set — GetValueRecursive traverses via that field and silently misbehaves or throws when it is null. Use ScreenSave for standalone state tests (no base type, no StandardElementsManager fallback).
InternalsVisibleTo is set up in Gum.ProjectServices.csproj for Gum.ProjectServices.Tests — internal members are directly accessible.
Integration Tests (MonoGameGum.IntegrationTests)
Use this project for anything requiring a real
GraphicsDevice. Each test creates a minimal nested Game subclass, calls game.RunOneFrame() to trigger Initialize, then asserts. See Tests/MonoGameGum.IntegrationTests/MonoGameGum/GumServiceUnitTests.cs for the established pattern. Always call LoaderManager.Self?.DisposeAndClear() in the Game.Dispose override to prevent state leaking across tests via the singleton.