Crates.io | bitt |
lib.rs | bitt |
version | 0.5.0 |
source | src |
created_at | 2024-01-17 23:28:52.217562 |
updated_at | 2024-03-02 09:53:15.561042 |
description | Bevy integration testing toolkit |
homepage | |
repository | https://github.com/haihala/Bevy-integration-testing-toolkit |
max_upload_size | |
id | 1103507 |
size | 31,509 |
Tool for integration testing apps built in the bevy game engine.
Bitt, (Noun) a pair of posts on the deck of a ship for fastening mooring lines or cables.
At the moment, only record/playback testing is implemented. To use it, add a system to your app that calls
bitt::Asserter::pass
when a test case is passed. Also add the bitt::PlaybackTestGear
plugin with the
name of the test case you want to use and a bitt::PlaybackTestingOptions
that configures the test gear.
Your inputs and artefacts will be saved under this name in
bitt/test_scripts/<script name>.bitt_script
and bitt/artefacts/<script name>
respectively.
If you then launch the game, it should run normally until bitt::Asserter::pass
is called, at which point
it will save the inputs. On a subsequent run, it will load the inputs and replay them. If the asserter doesn't
pass after the inputs are done, it panics which causes a non-zero return code, which can be used to fail a CI.
There is a bit of wiggle room for when the asserters are checked. A screenshot is saved in the artefacts folder
both before and after this window.
For examples, see:
crates/star_demo/src/bin/star_test.rs
for how to use the input recording and playback for keyboard/controller inputs.
crates/click_demo/src/main.rs
for a different approach to playback testing a mouse driven game.
.github/workflows/commit-validation.yml
for how to run the integration tests in a github action.
Warnings and caveats:
Recommendations:
bitt/test_scripts
in the repo, but gitignore bitt/artefacts
.cargo-make
to run the integration testsclap
to parse command line arguments instead of using env vars to select test casesFeedback and contributions are welcome. Please open an issue on github if you have any feedback or suggestions. Some ideas I've had:
You can also find me on the bevy discord as @hajhawa
.
Bevy version | BITT version |
---|---|
0.13 | 0.5 |
0.12 | 0.3 |
You may need to re-record your tests when upgrading to a new version of Bevy.