-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Add convenience methods for integration testing the ECS #3814
Copy link
Copy link
Open
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-UsabilityA targeted quality-of-life change that makes Bevy easier to useA targeted quality-of-life change that makes Bevy easier to use
Description
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-UsabilityA targeted quality-of-life change that makes Bevy easier to useA targeted quality-of-life change that makes Bevy easier to use