# Testing

> Test a Minekube game at three levels - its rules in Bun, its recorded sessions replayed through today's rules, and the whole game on a real server with bot clients that play it.

A Minekube game is easy to test because its rules import no Java. The same rules run on the server, in Bun under a test, and in the devtools. And every revision on the server records what happened as data, so a session someone played becomes a test.

| Level | Tool | Proves | Needs |
| --- | --- | --- | --- |
| Rules | `Story`, `Story.explore` | What each message does to the Model and which Commands it issues, in every order up to a depth | Bun |
| Recorded sessions | `Story.fromLog` over `recordings/*.ndjson` | A real session on the server still follows today's rules | Bun |
| Bot clients | `mk daemon`, `@minekube/client` | The whole game on a real server, from a real player's view | The dev server, Java 25 |
| Play | `mk dev .` and the devtools | How the game feels, with you in it | The dev server and Minecraft |

Run the first two with `bun test`. They take milliseconds, so run them on every save. The tests `mk init` creates in `src/Round.test.ts` cover both.

- [Test rules with Stories](https://minekube.com/games/testing/rules)
- [Recordings and replay](https://minekube.com/games/testing/recordings)
- [Test with bot clients](https://minekube.com/games/testing/bots)
- [The agent loop](https://minekube.com/games/testing/agent-loop)
- [Devtools and message logs](https://minekube.com/games/testing/devtools)

## Stories

A Story starts a component, sends it messages and checks every Command it issues. `Story.explore` tries every order of a set of messages. See [Test rules with Stories](https://minekube.com/games/testing/rules).

## Recordings

Every revision on the server writes its message log to `plugins/Minekube/recordings/<game>/`. See [Recordings and replay](https://minekube.com/games/testing/recordings#recordings).

## Replays

A recording copied into `recordings/` replays through your current rules in `bun test`. See [Recordings and replay](https://minekube.com/games/testing/recordings#replays).

## Play

`mk dev .` installs the game on the dev server, and the [devtools](https://minekube.com/games/testing/devtools) show its session live while you play. A [bot client](https://minekube.com/games/testing/bots) plays it without you, and a coding agent can drive the whole [loop](https://minekube.com/games/testing/agent-loop).
