A trickster online inspired wannabe RPG
Kimo Kimo.Tests
47 files

AdaptiveWorldTests.fs
AITests.fs
AnimationTests.fs
ArchetypeTests.fs
CameraTests.fs
CastingTests.fs
CombatDamageTests.fs
CombatFormulaTests.fs
CombatStatsTests.fs
CombatTests.fs
DataTests.fs
DiagnosticsTests.fs
DomainTests.fs
EffectsTests.fs
EntitiesTests.fs
InputTests.fs
IntentTests.fs
ItemSeedTests.fs
ItemTests.fs
Kimo.Tests.fsproj
Main.fs
MapTests.fs
MovementTests.fs
NavigationTests.fs
OrbitalTests.fs
ParticleTests.fs
PassiveTests.fs
PlayersTests.fs
PlayerStoreTests.fs
ProgressionTests.fs
ProjectileTests.fs
README.md
RegionTests.fs
ResourceTests.fs
RouterTests.fs
ScatterTests.fs
ScreenRegionsTests.fs
SeedSkillTests.fs
ShapesTests.fs
SpatialTests.fs
SpawningTests.fs
TerrainTests.fs
TestData.fs
TreeTests.fs
VfxTests.fs
WorldConfigBuilderTests.fs
WorldManagerTests.fs
README.md

Kimo.Tests #

The Expecto test suite for the game library. Run it from the repository root:

dotnet test Kimo.Tests

A new test file needs two registrations: the Compile list in Kimo.Tests.fsproj and the allTests list in Main.fs.

What a test must be #

These rules are not suggestions. A test that breaks them does not join the suite, even when it is green.

  1. Assert behavior, not plumbing. Test through the surface that is meant to survive: post input through the engine, step it, assert on the packed frame - the data the game actually reads. Never assert on message dispatch, envelopes, queue contents, or demo fields. A test must not freeze transitional machinery.

  2. Regression tests prove both directions. A regression test for a bug must fail before the fix and pass after it. Run it against the unfixed code before you keep it.

  3. Test-owned data only. Never assert production seed values. Fixtures live in TestData.fs (skill ids in the reserved 900+ range, test_* definition keys, test-owned items) and every expected number derives from them. Tests that need a world author their own configuration (withE2EWorld and the e2e* worlds in AdaptiveWorldTests.fs), never the gameplay seeds.

  4. The API is never shaped for tests. Do not add return values, flags, or getters so a test can assert. Commands return unit; a rejected input leaves the store unchanged; availability is queried through the read surface (TryGet, TryActive, the packed frame). Tests accommodate the API, never the reverse.

  5. No dev shortcuts, no key bindings. Name and trigger the behavior ("leaving the world ends membership"), never the key or menu item that happens to trigger it. Key bindings may drive the production input handler only where input routing itself is under test.

  6. Respect the step lanes. runner.Post lands in the intents lane, which drains after Update in the same step, so enqueued widget actions need two steps before their effect shows - use the drainWidgetLane helper in RouterTests.fs. Players and their entries do not exist until a real device press joins them: join through the real input handlers before you assert seating, screens, or stores.

  7. End to end is the shape for regressions. A mid-level test (direct calls over hand-built data) may stay when it pins a distinct contract, but a real bug gets a test that drives the real world: post through the engine, step, assert on the packed frame.

  8. Read the packed frame, never the live model. The world's adaptive graph belongs to the world thread (the engine confines it there), so forcing live projections (GetLiveModel, TryDerived, AMap.force) from the test thread is off-contract and can silently serve stale values that never recover. Assert through the FrozenWorldFrame the step returns or publishes (TryGetLatestFrame) - it is the only sim-to-test boundary. If the value you need is not in the frame, the test data is wrong: author the fixture so the effect lands on a frame-carried row (e.g. a max-HP buff reads through Vitals).

Where the helpers live #

  • TestData.fs - test-owned skills, items, seeds, and buildStores.
  • AdaptiveWorldTests.fs - world harnesses: withAdaptiveWorld, withTestWorld, withE2EWorld, and the e2e* owned world configurations.
  • RouterTests.fs - shell harnesses, including drainWidgetLane.