Reputation: 370
I refactored from Dagger2 to Hilt. Everything is fine except my Fragment Instrumentation tests. They are failing with this error:
java.lang.RuntimeException: Unable to resolve activity for: Intent {
act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER]
cmp=com.example.movies/.HiltTestActivity (has extras) }
Test Setup
@Test
fun movieDetailFragmentTest() {
// setup
launchFragmentInHiltContainer<MovieDetailFragment>(
fragmentFactory = fragmentFactory,
fragmentArgs = bundleOf(MOVIE_DETAIL_SELECTED_MOVIE_BUNDLE_KEY to testMovie)
) {
this.viewLifecycleOwnerLiveData.observeForever { viewLifecycleOwner ->
if (viewLifecycleOwner != null) {
Navigation.setViewNavController(this.requireView(), navController)
}
}
}
I got the launchFragmentInHiltContainer code from the google architecture samples as the recommended way. I have a HiltTestActivity and manifest file in the debug folder.
Im not sure what else I can do to get this to work. It worked out of the box with dagger2. Any help root causing this would be greatly appreciated.
Upvotes: 3
Views: 1072
Reputation: 370
The additional manifest that needs to be added to the debug folder along with the HiltTestactivity.kt. That manifest needs to be placed in the root debug folder not in the java folder or package. This solved the issue.
Upvotes: 4