Swapping fakes in tests
Fakes over mocks
Module 14 built WalkerRepository behind an interface β the ViewModel only ever calls repository.walks, never anything Room- or Retrofit-specific. That interface is what makes testing easy: instead of a mocking library faking method calls one by one, you write one small FakeWalkerRepository class implementing the interface with canned, in-memory data. A fake is real code that really runs β closer to production behavior, and far less brittle than a mock rebuilt every time a method signature changes.
@HiltAndroidTest on a test class turns on Hilt's test support, generating a test-specific version of the app's dependency graph. From there, @TestInstallIn lets you swap one @Module for another for the whole test source set β so any test that would otherwise pull in the real NetworkModule gets your fake instead, with zero changes to WalkersViewModel or the composable.