java.lang.IllegalStateException: Method addObserver must be called on the main thread.
Line navController.setGraph(R.navigation.navigation_onboarding)
`@RunWith(AndroidJUnit4::class)
class UserEmailFragmentTest {
@get:Rule
val activityRule = activityScenarioRule<OnboardingActivity>()
@Test
fun verifyAllRequiredViewsAreDisplayed() {
// Create a TestNavHostController
val navController = TestNavHostController(
ApplicationProvider.getApplicationContext()
)
navController.setGraph(R.navigation.navigation_onboarding)
// Create a graphical FragmentScenario for the TitleScreen
val userEmailScenario = launchFragmentInContainer<EmailFragment>()
// Set the NavController property on the fragment
userEmailScenario.onFragment { fragment ->
Navigation.setViewNavController(fragment.requireView(), navController)
}
assertThat(navController.currentDestination?.id).isEqualTo(R.id.emailFragment)
}
java.lang.IllegalStateException: Method addObserver must be called on the main thread. Line navController.setGraph(R.navigation.navigation_onboarding)
`@RunWith(AndroidJUnit4::class) class UserEmailFragmentTest {
}`