Sobes.tech
Middle

How would you test the functionality of an advertising banner? (The link to the image and the timer are taken from the backend response when launching the application)

sobes.tech AI

Answer from AI

To verify the operation of an advertising banner when the image link and timer are received from the backend at app startup, you can do the following:

  1. Banner loading check:

    • Ensure that at app start, the request to the backend successfully retrieves the image URL and timer value.
    • Verify that the banner is displayed on the screen with the correct image (for example, check that the ImageView element contains the correct URL or loaded image).
  2. Timer check:

    • Ensure that the timer starts with the received value.
    • Check that after the timer expires, the banner is hidden or changes according to the requirements.
  3. Interaction check:

    • If the banner is clickable, verify that clicking it triggers the expected action (for example, navigating to a link).
  4. Automation:

    • Write a UI test that mocks the backend response with the specified URL and timer.
    • Check the display and behavior of the banner over time.

Example in Kotlin using Espresso to verify banner display:

// Check that the ImageView with id bannerImageView displays the image
onView(withId(R.id.bannerImageView))
    .check(matches(isDisplayed()))
    .check(matches(withTagValue(equalTo(expectedImageUrl))))

// Check that the banner disappears after the timer
Thread.sleep(timerValueInMillis + 500) // wait for the timer
onView(withId(R.id.bannerImageView))
    .check(matches(not(isDisplayed())))

Thus, it verifies the correctness of data retrieval, display, and banner behavior.