-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide a way to test Bevy App #2896
Comments
This is already partially supported and used on CI: Line 248 in 5ba2b9a
The bevy/.github/example-run/alien_cake_addict.ron Lines 1 to 3 in 5ba2b9a
|
You can run a crash test, but it's not robust enough to cover logical/game behavior errors from user point of view. In a context of ECS where the framework take control of the application, I think this should be something like this :
|
This is now approximately solved (see #1057) for more status. It just needs a proper example in Bevy, probably in the If you're looking to tackle this, feel free to steal from my own work without attribution. |
For clarity, this issue is not solved (#1057 actually redirects here) and all related issues point to this one as the tracking one. This is still very much an open issue; even without any mocking involved, it's impossible to run an app with
|
That error will be related to |
Thanks for the explanation @alice-i-cecile. It would be good to have an exhaustive list of the blockers listed on this GitHub issue (or others). I think there's that Unfortunately there's no easy way to test any |
Audio is also likely to be challenging to test in CI. Our screenshotting and input mocking tools are also limited. |
But are those really blockers, or just missing tools for specific test types? What I was listing were things that I think block |
I have been pretty successfully testing systems that just tweak data (rather than graphical side effects) by making headless windows, disabling winit, and manually fast-forwarding time in between calls to Basic gist is something like:
|
Note: This above is fine if you don't need anything from rendering. Unfortunately this skips the entire init of the |
Wait, why do you need the second one? That seems unrelated 🤔 |
# Objective This older PR from `Wcubed` seemed well worth saving, adopted from #7314. See also tracking issue #2896 for ongoing discussion of Bevy testability. Thanks `Wcubed`! ## Solution - Updated for 0.15 - Added the `expected`/`actual` pattern - Switched to function plugin - Tweaked a bit of description ## Testing Green. --------- Co-authored-by: Wybe Westra <dev@wwestra.nl> Co-authored-by: Wybe Westra <wybe.westra@protonmail.com>
# Objective This older PR from `Wcubed` seemed well worth saving, adopted from bevyengine#7314. See also tracking issue bevyengine#2896 for ongoing discussion of Bevy testability. Thanks `Wcubed`! ## Solution - Updated for 0.15 - Added the `expected`/`actual` pattern - Switched to function plugin - Tweaked a bit of description ## Testing Green. --------- Co-authored-by: Wybe Westra <dev@wwestra.nl> Co-authored-by: Wybe Westra <wybe.westra@protonmail.com>
What problem does this solve or what need does it fill?
Bevy App should be testable in headless mode (no renderer), for Continuous Integration and fast feedback when user logic / system interaction is not what user intendeed.
What solution would you like?
Idealy, a complete example for testing a Bevy App should be provided out of the box.
Currently, there's a minimal example provided here : https://github.com/bevyengine/bevy/blob/main/crates/bevy_ecs/examples/resources.rs
This doesn't work well because you have no way to test things that happen "later in time". You advance Bevy synchronously with iteration in a for loop. If you sleep the main thread between each iteration, you'll advance in time but the side effect is test will be slower. So this example work well for startup system or system that run each tick, but this doesn't work for system that happen "later" in time.
We need a way to test a Bevy Application and travel time to a future point where Bevy State is updated, so assertion can work, for all case (FixedTimeStep System or not).
What alternative(s) have you considered?
Don't bother with testing, stay like this.
Honestly, for small Bevy App you don't need test, but for complex system interaction it's a nice feature.
I'm confident about Bevy behavior and logic, but I don't trust my own code especially when it's inverted control (https://en.wikipedia.org/wiki/Inversion_of_control, the framework is responsible to run my application).
A nice side effect of this feature is if you make Bevy easily testable (out of the box with cargo test), contributors will have a better understanding of Bevy code base/change.
Additional context
Related : #1057 and #1720 and #2687
The text was updated successfully, but these errors were encountered: