You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
I'm trying to test ViewModel on Unit test.
But, I can't use @Inject on ViewModel. I can't found any documentation about @HiltViewModel Unit test.
How can I test it? Is there any documentation?
error: [dagger.hilt.android.processor.internal.viewmodel.ViewModelValidationPlugin]
public abstract static class SingletonC implements AmphibiansApplication_GeneratedInjector,
^
Injection of an @HiltViewModel class is prohibited since it does not create a ViewModel instance correctly.
Access the ViewModel via the Android APIs (e.g. ViewModelProvider) instead.
Injected ViewModel: com.example.myapplication.ui.AmphibiansViewModel
com.example.myapplication.ui.AmphibiansViewModel is injected at
com.example.myapplication.AmphibiansViewModelTest.amphibiansViewModel
com.example.myapplication.AmphibiansViewModelTest is injected at
com.example.myapplication.AmphibiansViewModelTest_GeneratedInjector.injectTest(com.example.myapplication.AmphibiansViewModelTest)
The text was updated successfully, but these errors were encountered:
Personally I've always written JVM tests for ViewModels where you just instantiate them normally and only wrote Android tests for components using the VMs — Fragments, Activities, compose functions. Any reason you don't want to write AmphibiansViewModelTest as a JVM test?
Hello,
I'm trying to test ViewModel on Unit test.
But, I can't use
@Inject
on ViewModel. I can't found any documentation about @HiltViewModel Unit test.How can I test it? Is there any documentation?
I'm using compose.
My ViewModel
And unit test code.
This is error message.
The text was updated successfully, but these errors were encountered: