-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Utility functions for integration testing #3839
Utility functions for integration testing #3839
Conversation
Very interested in this topic. In the past I've used a minimal App, a |
@shanesveller This PR is now ready for review; I'd love to hear what you think of the end result. |
Overall, I think this is very useful, but this seems like something that should be behind a #[cfg(test)] conditional, or separated out entirely an optional dev-dependency. It's definitely not optimal to be compiling testing code into production binaries, even if it gets optimized out. |
That's an interesting idea. I think that I agree with you on the assertions, but the other helpers have important non-testing uses (even if they don't enable new functionality). I'll shuffle this around. |
I would prefer those methods to not be available during standard development, but they should be documented on docs.rs. I think the best way to have both would be to have everything in a
|
That could be an interesting pattern to show for tests: put all your invariants check in a system, and run that systems after an update |
I think I agree with basically all of your proposals. I'll make those changes and then re-request review :) |
Alright, so I think this is the best we can do for now. Fundamentally, I want to be able to query the world in a single line, but, because query is assumed to have a cached state stored somewhere, this is impossible. The only decent work-around is to include special-cased helper methods, to reduce the intense boilerplate of checking "is this value what I expect". In the long run, I very much want a better solution, but that will involve much more serious design work and engine refactoring. |
Closing this out in favor of something more scoped. |
Objective
Solution
World
Limitations
Input mocking has not been included. Fundamentally; we need an abstraction over the input methods to handle this nicely.
See https://github.com/Leafwing-Studios/leafwing-input-manager/blob/main/src/input_mocking.rs for an external implementation of this.
Working with queries in integration tests still fundamentally sucks, because of the need to store query state somewhere. As a result, I've included some uncomfortably special-cased helpers.
TODO
set_component
run_system