i am a newbie to android testing. i am trying to test a login fragment which has email and password fields and a login button. when i click on that button i should get redirected to a dashboard fragment. here is code for the test->
@RunWith(JUnit4::class)
@LargeTest
class LoginSuccessTest {
private lateinit var scenario: FragmentScenario<LoginFragment>
//run the login fragment
@Before
fun setupTestEnvironment() {
scenario = launchFragment()
scenario.moveToState(Lifecycle.State.STARTED)
}
@Test
public fun loginSuccess()
{
//enter email and password
onView(withId(R.id.emailEt)).perform(typeText("abc@gmail.com"))
onView(withId(R.id.passwordEt)).perform(typeText("abctest123"))
//close on-screen keyboard
Espresso.closeSoftKeyboard()
//click on sign in button
onView(withId(R.id.login)).perform(click())
// successful login moves user to next screen
val scenarioDashboardFragment = launchFragment<DashboardFragment>()
scenarioDashboardFragment.moveToState(Lifecycle.State.STARTED)
}
}
when i run this test i get an error related to creating fragment view->
android.view.InflateException: Binary XML file line #42 in //fragment layout file
Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 1: TypedValue{t=0x2/d=0x7f030008 a=-1}
can anyone help and please tell me if there is something wrong with code or logic? the code is written in kotlin language.