Skip to content

Automated test for Bevy through BRP#23647

Open
mockersf wants to merge 4 commits intobevyengine:mainfrom
mockersf:old-school-automated-tests
Open

Automated test for Bevy through BRP#23647
mockersf wants to merge 4 commits intobevyengine:mainfrom
mockersf:old-school-automated-tests

Conversation

@mockersf
Copy link
Copy Markdown
Member

@mockersf mockersf commented Apr 3, 2026

Objective

  • Show how a Bevy app can be automated through BRP

Solution

  • Example app_under_test is a basic app with a randomly placed button. when the button is clicked, the app quit
  • Example automated_test click that button through BRP using WindowEvent so that it goes through the whole of Bevy

Testing

  • Run both example and they both exit

@mockersf mockersf force-pushed the old-school-automated-tests branch from 3679862 to 0e1f61c Compare April 3, 2026 18:01
@mockersf mockersf force-pushed the old-school-automated-tests branch from 0e1f61c to 6750aa1 Compare April 3, 2026 18:02
@kfc35 kfc35 added C-Examples An addition or correction to our examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward A-Dev-Tools Tools used to debug Bevy applications. labels Apr 3, 2026
@kfc35 kfc35 self-requested a review April 3, 2026 23:10
Copy link
Copy Markdown
Contributor

@kfc35 kfc35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the value in these examples as is (to demonstrate manipulating a live-app for testing purposes), but I wonder if these examples could be made more compelling by exploring it from the prospective of an app creator attempting to incorporate automated tests into their project.

For example, it might be helpful to setup how this could look if someone wants to have these automated tests run in CI by giving an example GitHub Action config or something alongside (although something like that might probably be in the works for this repo itself?, in which case I would just express that such a setup may be useful to share with app creators as well!).

I’m also not sure if the phrase “Automated Test” sounds too vague for what this is. I would liken this to an “(End-to-end?) Integration Test" since it tests running a whole app.

//! Run with the `bevy_remote` feature enabled:
//! ```bash
//! cargo run --example app_under_test --features="bevy_remote"
//! ```
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to link back to the other example in some way optionally

Suggested change
//! ```
//! ```
//! This example can be paired with the `automated_test` example, which will run an automated
//! test on this app.


fn move_button(mut rng: ResMut<SeededRng>, mut button_query: Query<&mut Node, With<Button>>) {
let (left_pct, top_pct) = random_position(&mut rng.0);
info!("Button moved to ({left_pct:.1}%, {top_pct:.1}%)");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think the example could be more compelling if these print statements were in logical coordinates to match what’s going on in automated_test so the viewer sees numbers match

fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugins(RemotePlugin::default())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.add_plugins(RemotePlugin::default())
// To make the app available for automated testing, we add these
// remote plugins to expose API’s for a testing framework to call.
.add_plugins(RemotePlugin::default())

@kfc35 kfc35 added C-Testing A change that impacts how we test Bevy or how users test their apps D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes labels Apr 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Dev-Tools Tools used to debug Bevy applications. C-Examples An addition or correction to our examples C-Testing A change that impacts how we test Bevy or how users test their apps D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants