โ† All Android Development Flashcard Decks

Android Testing Flashcards

6 cards from real Android Development practice questions. Tap to flip, then mark Knew It or Still Learning โ€” missed cards come back until you master them.

Read the first 6 Android Testing flashcards as text
  1. Which Espresso method is used to find a view by its resource ID?

    Answer: onView(withId())

    onView(withId(R.id.viewId)) finds the view with the specified resource ID in Espresso UI tests.

  2. What is Robolectric used for in Android testing?

    Answer: Running Android instrumentation tests on the JVM without a device or emulator

    Robolectric simulates the Android framework on the JVM, allowing instrumentation-style tests to run locally without needing a device.

  3. What does the @Before annotation do in JUnit?

    Answer: Marks a method to run before each test method in the class

    @Before marks a method that JUnit executes before each @Test method, commonly used for test setup like initializing objects.

  4. Which Espresso method simulates a button click in a UI test?

    Answer: perform(click())

    In Espresso, perform(click()) is chained after onView() to simulate a user tapping on the matched view.

  5. What is the TestCoroutineDispatcher used for in Android testing?

    Answer: To control coroutine execution timing in tests for deterministic behavior

    TestCoroutineDispatcher (or UnconfinedTestDispatcher) allows tests to control when coroutines run, enabling synchronous and deterministic coroutine testing.

  6. What is the purpose of the Truth assertion library in Android testing?

    Answer: To provide fluent, readable assertion methods as an alternative to JUnit assertions

    Google's Truth library provides a fluent API for writing assertions that produce more readable failure messages than standard JUnit assertions.