← All work

Open source · Case study

Rusty Chess

A chess game in Rust and Bevy written test-first: 286 tests, and tagged releases that build WebAssembly and publish a playable demo.

Author · Personal project · 2024 – Present

  • 286automated tests
  • Live demoplayable in the browser
  • Tag → releaseautomated publishing

The problem

I wanted to know how far strict test-driven development goes in Rust on a problem with real rules complexity: check, checkmate, stalemate and per-piece movement.

What I built

  • The full rules of chess as a library with no dependency on the game engine.
  • A Bevy front end that calls the same public API the tests use.
  • A pipeline that checks formatting and runs every test on each push, and a release workflow that builds WebAssembly and publishes to itch.io when a version is tagged.

Decisions and tradeoffs

Rules as a library, engine as a thin shell

The crate is split into a library and a three-line binary. The rules can be tested without starting a window, and the integration tests play whole games through the public API.

Two layers of tests

279 unit tests sit next to the code for each piece and the board. 7 integration tests play complete games such as Fool's mate and Scholar's mate, which catches errors that only appear when rules interact.

Releases are tags

Publishing is a git tag, not a manual upload. The tradeoff is a slower first release while the workflow was written; every release since has been one command.

Results

  • 286 tests run on every push: 279 unit tests and 7 full-game integration tests.
  • A playable demo in the browser, published by the release workflow.

Built with

  • Rust
  • Bevy
  • WebAssembly
  • Test-driven development
  • GitHub Actions

← Back to all work · Get in touch