title: How to implement count down timer for UI Testing in Espresso kotlin?
body: <p>I am trying to implement count down timer in UI testing using Espresso.
  I want to achieve something like this:  I want to update UI (textview) in parallel with on tick method in the test class in kotlin.</p>
  <pre><code>@RunWith(AndroidJUnit4::class)
  class TimerActivityTest {
      
      private var mIdlingResource: IdlingResource? = null
      
      @get : Rule
      val activityScenarioRule =  ActivityScenarioRule(TimerActivity::class.java)
      
      @Before
      fun registerIdlingResource() {
          val activityScenario: ActivityScenario&lt;*&gt; =
          ActivityScenario.launch(TimerActivity::class.java)
          activityScenario.onActivity {
              it?.let {
                  mIdlingResource = (it as TimerActivity).getIdlingResource()
                  // To prove that the test fails, omit this call:
                  IdlingRegistry.getInstance().register(mIdlingResource)
              }
          }
      }
      
      @After
      fun unregisterIdlingResource() {
          if (mIdlingResource != null) {
              IdlingRegistry.getInstance().unregister(mIdlingResource)
          }
      }
      
      @Test
      fun startTimer() {
          onView(withId(R.id.tvTime))
              .check(matches(withText(&quot;00:00&quot;)))
      }
  }
  </code></pre>
  <p><strong>Issue</strong>: After running this code, the test case is canceled in 2 seconds.</p>
  <p>Thanks in Advance.</p>