Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is Espresso's registerIdlingResources deprecated, and what replaces it?

I'm working on UI tests with Espresso for Android, and following the Google's code sample it is used, even though it's deprecated. So my questions are:

  • why is it deprecated?
  • what replaces it?
like image 820
Marvin Effing Avatar asked Nov 02 '17 14:11

Marvin Effing


2 Answers

Since the example has not been updated, if you are using Espresso 3.0< instead of registerIdlingResources

Espresso.registerIdlingResources(mIdlingResource);

you should use IdlingRegistry:

IdlingRegistry.getInstance().register(mIdlingResource);
like image 161
grrrrrr Avatar answered Oct 19 '22 09:10

grrrrrr


I'm working on unit tests with Espresso

I hope you mean UI tests ;)

why is it deprecated?

Some apps use build flavors in Gradle or a dependency injection framework, like Dagger, to generate test build configurations that register idling resources. Others simply expose the idling resource through their activities. The problem with all these approaches is that they add complexity to your development workflow, and some of them even break encapsulation.

what replaces it?

Now you need to use IdlingRegistry API

Source: Android Testing Support Library 1.0

like image 21
cherif Avatar answered Oct 19 '22 11:10

cherif