Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Slow down Espresso

this is regarding Espresso. I am successfully running integration test on a simulator. I think some tests are failing because it's running too fast. Is there a way to slowdown the execution/playback speeD?

like image 672
SIr Codealot Avatar asked Mar 23 '16 00:03

SIr Codealot


People also ask

How do you make an espresso slower?

Pump Pressure and Flowrate Just know that the lower the pressure, the slower your espresso shots will run and the lower the flow rate will be. In terms of flowrate, most machines are somewhere between 250 and 500ml/30sec.

Why is my espresso shot coming out too fast?

If the shot is coming out too fast, grind finer the coarser the coffee the faster the flow. If your shot is too strong, it could be a function of either too large of a dose, or too little water. Also, double check your brew pressure.

What is the 10 second rule for espresso?

It takes 10 seconds for an espresso shot to “go bad”. That is, for the heart, body and crema to blend together into a big black bitter mess. If you're drinking espresso straight, it doesn't matter.


2 Answers

It's impossible that a test fails cause to speed. Espresso can synchronize all test operations with the application under test. By default, Espresso waits for UI events in the current message queue to process and default AsyncTasks to complete before it moves on to the next test operation. However if this is not enough for your application you can tell Espresso when to be idle and when not. To do so you have to :

  • Implement the IdlingResource interface.
  • Register one or more of your IdlingResource(s) with Espresso by calling Espresso.registerIdlingResource in test setup.

If you need more help ask me!!

like image 104
Lorenzo Camaione Avatar answered Oct 11 '22 07:10

Lorenzo Camaione


When you record an Espresso Test in Android Studio it will automatically add Sleep statements to tests when there is view interaction to handle the delay. This is the approach that is generated along with the comments:

// Added a sleep statement to match the app's execution delay.
// The recommended way to handle such scenarios is to use Espresso idling resources:
// https://google.github.io/android-testing-support-library/docs/espresso/idling-resource/index.html

try {
    Thread.sleep(700);
} catch (InterruptedException e) {
    e.printStackTrace();
}

Link to the docs

like image 39
robotsquidward Avatar answered Oct 11 '22 07:10

robotsquidward