Closed oscargus closed 2 weeks ago
What current test strategies exist for egui applications? I'm looking to feature/system test an app using egui and am lookong at where to start.
I'm coming from web where interfaces are pretty easy to test since assertion against DOM state is trivial/well supported.
Not sure if is counts as a test strategy, but in Surfer we use egui_skia https://github.com/lucasmerlin/egui_skia (but a local version that supports egui 0.25, we still need to add support for 0.26) and generate images that we compare. See https://gitlab.com/surfer-project/surfer/-/blob/main/src/tests/snapshot.rs?ref_type=heads
Limitations are (among others):
Still, it gives us some code coverage and tests have helped us from breaking stuff unintentionally so we think it is worth it.
Is your feature request related to a problem? Please describe.
To improve regression testing, it would be nice if there is was a mechanism to "inject" mouse and keyboard presses from code. (I guess there may be, just that it is not that simple to figure out how.)
Describe the solution you'd like
Ideally a testing framework to make it easier to test egui applications. However, a clear described mechanism to force certain events would be a first step.
Describe alternatives you've considered
Additional context
This is somewhat related to https://github.com/emilk/egui/issues/1129 (we are using egui-skia to generate test images, but can only test features triggered by messages, not "pressing" keys/mouse buttons in suitable areas).