Library to enable testing applications made with Evergine, inspired on Xamarin.Forms.Mocks.
Goals:
- Enable testing components and behaviors
Out of scope:
- Enable testing drawables or anything related to rendering
The most of our applications contain a bunch of components (it-self, or behaviors/drawables) which contain logic. Such components, usually, consume other artifacts from outside:
- other components
- services
- managers
- entities from its hierarchy
Beacause of this, isolating a component for testing is quite complicated. However, we can rely on a mock Windows System which, in a headless fashion, replicates the same behavior the app would have.
- running single update-draw loop on demand
- reading actual Content
- BindComponent attribute
- BindService attribute
- Camera3D.Display
- mock KeyboardDispatcher
- mock MouseDispatcher
- mock TouchDispatcher
- Leave Application.Initialize() empty: refactor its entire logic into a separate public method, called from each WindowsSystem
- This is needed to avoid tests to set the ScreenContext up and navigate to an actual Scene by default
windowsSystem.Run(
() =>
{
// Pull initialization logic from here...
application.Initialize();
// to here
application.NavigateToMainScene();
},
() =>
{
[...]
});
- Execute tests sequentially: Evergine currently does not support running tests in parallel
- You can see how to do it with xUnit here
- New GraphicsBackend value: Mock, None, Test
- Maybe: Allow running tests in parallel (it seems there are some static references preventing such)