Fragment is not loading in Unit Test.
Code:
@RunWith(AndroidJUnit4::class)
class DataFeature {
@Test
fun testEventFragment() {
val fragmentArgs = bundleOf("test" to "100")
val scenario = launchFragmentInContainer<DetailFragment>(fragmentArgs)
}
}
Error:
java.lang.IllegalStateException: Hilt Fragments must be attached to an @AndroidEntryPoint Activity. Found: class androidx.fragment.app.testing.FragmentScenario$EmptyFragmentActivity
Fragment file
@AndroidEntryPoint
class DetailFragment : Fragment() {....}
while I am using Hilt in my application code. It's showing error in test case. It's not launching that fragment. I am using jetpack navigation controller as well.
Any help would be appreciated! Thanks in Advance.