#testing-tools #fixtures #rstest #plugin #assets #event-collector

nightly rmv-bevy-testing-tools

Write simple tests for bevy systems, using rstest, insta, and speculoos

11 unstable releases (3 breaking)

new 0.5.3 Apr 17, 2025
0.5.2 Apr 15, 2025
0.5.1 Feb 6, 2025
0.5.0 Jan 25, 2025
0.2.0 Jul 23, 2024

#347 in Testing

Download history 209/week @ 2025-01-09 235/week @ 2025-01-16 107/week @ 2025-01-23 8/week @ 2025-01-30 133/week @ 2025-02-06 11/week @ 2025-02-13 2/week @ 2025-02-20 67/week @ 2025-04-10

67 downloads per month

MIT license

30KB
754 lines

rmv-bevy-testing-tools

TestApp

use super::{MySimplePlugin, MyGamePlugin};
use rstest::rstest;
use rmv_bevy_testing_tools::{test_app, TestApp};

#[rstest]
fn test_my_simple_plugin(#[with(MySimplePlugin)] mut minimal_test_app: TestApp) {
    // run system tests
}
#[rstest]
fn test_my_plugin(#[with(MyGamePlugin)] mut test_app: TestApp) {
    // run systems tests involving assets
}

#[fixture]
pub fn my_custom_test_app() -> TestApp {
    let mut app = App::new();
    app.add_plugins((
        // add your plugins
    ));
    TestApp(app)
}

#[fixture]
pub fn my_configurable_custom_test_app<P>(
    #[default(())]
    plugins: impl Plugins<P>
) -> TestApp {
    let mut app = App::new();

    app.add_plugins((
        // add your plugins
        plugins,
    ));

    TestApp(app)
}

EventCollector


use rmv_bevy_testing_tools::{test_app, EventCollector, GetCollectedEvents, TestApp};
use rstest::rstest;
use speculoos::{assert_that, option::OptionAssertions};

#[derive(Event, Clone, Debug, PartialEq)]
struct MyEvent;

#[rstest]
fn test_events(
    #[with((
        GamePlugin,
        EventCollector::<MyEvent>::new()
    ))]
    mut test_app: TestApp,
) {
    test_app.update();
    let events = test_app.get_collected_events::<MyEvent>();
    assert_that!(&events)
        .named("collected events")
        .is_some()
        .is_equal_to(vec![]);
}

Dependencies

~44–76MB
~1.5M SLoC