I use dagger hilt
in my project. I want to write UI test
for some fragments. I need to mock the viewModel
in the test class and associate it to the fragment under the test.. I read dagger hilt
document but I didn't find any solution.
class HomeViewModel @ViewModelInject constructor(
private val repository: MainRepository,
prefManager: PrefManager,
private val firebaseAnalytics: FirebaseAnalytics,
@Assisted private val savedStateHandle: SavedStateHandle
) : ViewModel() {
/////
}
@AndroidEntryPoint
class HomeFragment : BaseFragment() {
private val viewModel: HomeViewModel by viewModels()
/////
}