I \'ve got a Quiz app using Realm db. Every time the user selects an answer she clicks a button and new text for Question appears. Thats it until she reaches the end where
For Devs using AndroidX for testing, things are a bit changed.
This is an example UI Test case for testing whether my intended activity opens after clicking on the textview.
import androidx.lifecycle.Lifecycle
import androidx.test.core.app.ActivityScenario
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions
import androidx.test.espresso.intent.Intents
import androidx.test.espresso.intent.Intents.intended
import androidx.test.espresso.intent.matcher.IntentMatchers.hasComponent
import androidx.test.espresso.matcher.ViewMatchers.withId
import com.softway.dhananjay.tournamentapp.tournament.TournamentActivity
import org.junit.Test
class MainActivityTest {
@Test
fun tournament_activity_starts_onClick_of_textView() {
Intents.init()
val activityScenario: ActivityScenario =
ActivityScenario.launch(MainActivity::class.java)
activityScenario.moveToState(Lifecycle.State.RESUMED)
onView(withId(R.id.startTextView)).perform(ViewActions.click())
intended(hasComponent(TournamentActivity::class.java.name))
Intents.release()
activityScenario.moveToState(Lifecycle.State.DESTROYED)
}
}