Disable Bevy renderer for tests
Building a bevy crate to ease 2D sprites animations, we wanted to use some parts of the SpritePlugin
crate (precisely the TextureAtlas
) which deeply rely on the RenderPlugin
.
Opening a window and testing rendering is not possible in tests/CI environments, which seems logic. So we needed to disable all these features to make our test pass.
Here is a basic code to run your Bevy app with no renderer and no window:
#[test]
fn sprite_time_is_updated() {
// Setup app
let mut app = App::new();
app.add_plugins(DefaultPlugins
.build()
.set(RenderPlugin {
render_creation: WgpuSettings {
backends: None,
..default()
}
.into(),
})
.disable::<WinitPlugin>());
// Now you can run your tests
}
Comments
Be the first to post a comment!