Skip to content

Add convenience methods for integration testing the ECS #3814

@alice-i-cecile

Description

@alice-i-cecile

What problem does this solve or what need does it fill?

Integration testing is important, but our existing tools for it are boilerplate-heavy.

What solution would you like?

There are a few patterns that come up very regularly, and should be supported directly on the App and World:

  • assert that the resource of the given type matches the provided value
  • assert that all components that match a query match the given tuple of values
  • assert that the number of entities returned by a query is n

Each method on App should just call the underlying method on World.

What alternative(s) have you considered?

These helper methods can be written entirely externally. However, this is suboptimal because:

  • friction is one of the largest barriers to testing
  • this code is going to be exactly the same across all serious products created with Bevy
  • Bevy itself should be integration tested, and would benefit from these ergonomics improvements

Additional context

This pattern is very useful when combined with manually calling app.update() in your integration tests.

#3786 would make organizing these sorts of ergonomics methods more convenient.

I've also written a number of tools for input-mocking that are very useful, but those should be considered in a separate issue / PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-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