Unit Testing View Models with a SceneCoordinator

I like the use of a SceneCoordinator within my view models to help facilitate MVVM. But I’m unsure of the right way to unit test my ViewModel classes. Mainly that a Scene Coordinator requires a window to be initialized.

How do I work around passing the SceneCoordinator when initializing a ViewModel?

You’re right, the init(window: Window) initializer should have been left out of the protocol and only added to the app implementation. I’ll fix this mistake in the next book update, thanks!

This topic was automatically closed after 166 days. New replies are no longer allowed.