1 shared test fixtures and fixture workspaces
forgejo-actions edited this page 2026-07-15 12:43:13 +00:00

Shared Test Fixtures And Fixture Workspaces

Purpose

Shared fixture helpers keep tests deterministic while still exercising real authored content paths. Use them when a test needs temporary files, a scoped asset root, or the canonical quest-guide authored fixture instead of ad hoc file setup.

Steps

  1. Use aether_test_support::FixtureWorkspace for tests that need a clean temporary repository-like root.
  2. Write files through write, append, replace, and rename so paths are normalized and remain inside the workspace.
  3. Use src/test_fixtures::asset_root::scoped_asset_root when code under test reads AETHER_ASSET_ROOT.
  4. Use the authored fixture manifest when a test needs matching scene, quest, NPC, and dialogue content.
  5. Keep fixture ids and source paths stable so editor, bake, runtime, and xtask tests can share the same regression story.

Expected Outputs

Fixture workspaces are removed when their last handle drops. Authored fixtures expose stable constants for scene, quest, NPC, dialogue, actor, placement, and catalog ids. Scoped asset roots restore the previous environment variable and reset runtime path caches when dropped.

Common Mistakes

Common mistakes include writing outside the fixture root, using .. in fixture paths, mutating AETHER_ASSET_ROOT without a scoped guard, duplicating the quest-guide fixture by hand, or relying on test execution order for shared state cleanup.

Recovery Paths

If a fixture path assertion fails, normalize the path and remove parent traversal. If asset-root dependent tests leak state, wrap the test in scoped_asset_root and avoid manual environment cleanup. If a regression test needs authored content, add it to the shared manifest rather than copying only one side of the scene, quest, NPC, or dialogue chain.