Skip to content

Using DefaultPlugins breaks for multiple tests due to LogPlugin #1969

Closed
@MJohnson459

Description

@MJohnson459

Bevy version

0.5

Operating system & version

Ubuntu 18.04

What you did

I am trying to write tests for systems and encounter this error when there are multiple tests

#[cfg(test)]
mod test_example {
    use super::*;

    fn setup() -> App {
        let mut builder = App::build();
        builder.add_plugins(DefaultPlugins);
        builder.app
    }

    #[test]
    fn test_one() {
        let _app = setup();
        assert!(true);
    }

    #[test]
    fn test_two() {
        let _app = setup();
        assert!(true);
    }
}

What you expected to happen

Log instances shouldn't conflict

What actually happened

Could not set global default tracing subscriber. If you've already set up a tracing subscriber, please disable LogPlugin from Bevy's DefaultPlugins

Additional information

A possible fix might be to remove the explicit panics if creating a global subscriber fails

.expect("Could not set global default tracing subscriber. If you've already set up a tracing subscriber, please disable LogPlugin from Bevy's DefaultPlugins");

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-BugAn unexpected or incorrect behaviorC-UsabilityA targeted quality-of-life change that makes Bevy easier to use

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions