Sign in Go Pro

Android MvRx Fundamentals

Test ViewModels

This lesson is for PRO members.

Upgrade today to get access to all the PRO lessons.

Unlock this lesson



Testing ViewModels is nearly as easy as testing state. In MvRx, all dependencies are constructor injected and ViewModels only have one lifecycle method (onCleared). To test ViewModels, just pass in implementations or mocks of your dependencies into your constructor, call functions on your ViewModel that affect state, and run assertions that your state was updated correctly.

This lesson will guide in configuring the mvrx-testing artifact which will ensure that your MvRx reducers run synchronously and will write a few tests for a MvRxViewModel.




There are no comments on this lesson, start the conversation below ...


Lessons in Android MvRx Fundamentals