How to intentionally slow down the emulator?

Viewed 2946

This question goes the opposite direction than the usual about Android emulators.

My Android instrumentation tests (using Espresso against the RxJava-based app) run just fine on my development machine, but they occasionally fail in the build server.

My build server has a slower hardware than my machine. I think this is causing the actual Espresso checks to be performed before the background tasks have been completed. I'm aware that Espresso, by default, does not wait for RxJava schedulers (io() and computation()) to complete, so that may be the reason.

There are several ways to make Espresso aware of RxJava schedulers, but before implementing them I want to reproduce the problem on my machine.

I've tried disabling hardware acceleration to no avail.

In the configuration you can set the network speed and latency, but in this case I'm interested in throttling down CPU speed. There is no network involved in the failing tests.

2 Answers

Try to edit configuration of your Emulator in AVD Manager, I just decreased RAM and Cores number and my tests started to fail more often:)

enter image description here

There's no way to slow down the Android emulator, and even it that was possible, it won't expose more race conditions because both "parts of the race" are slowed down together, in this case Espresso and RxJava's background tasks.

It's better to focus instead on reproducing locally the same environment where the issue occurred.

Related