#testing-tools #bevy #plugin #rstest #speculoos #rmv

nightly rmv-bevy-testing-tools

Testing-utilities for integrating rstest, insta, and speculoos with bevy

6 releases

new 0.4.0 Jan 16, 2025
0.3.0 Jan 16, 2025
0.2.3 Jan 12, 2025
0.2.0 Jul 23, 2024

#404 in Testing

Download history 10/week @ 2024-09-25 4/week @ 2024-10-02 2/week @ 2024-12-04 7/week @ 2024-12-11 264/week @ 2025-01-08

264 downloads per month

MIT license

21KB
463 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

~41–73MB
~1.5M SLoC