I have a few classes to test deep links. Each class test 1 deep link.
There are few tests that always terminate correctly at 10+ seconds when I run them individually but always take more than 45 seconds to finish when I run them together.

Note that all these tests are supposed to fail all the times now (I haven't done the implementation for them) so the results should not vary.
Am I using IdlingPolicies.setIdlingResourceTimeout wrong?
My test class:
@RunWith(AndroidJUnit4.class)
public class DeepLinkActivityBagTest extends MyActivityTest {
@Rule
public MyActivityTestRule<DeepLinkActivity> activityTestRule =
new MyActivityTestRule<DeepLinkActivity>(DeepLinkActivity.class) {
@Override
protected Intent getActivityIntent() {
Intent intent = super.getActivityIntent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.parse("xxx://bag"));
return intent;
}
};
@Test
public void testCorrectScreenOpened() {
setUpWait();
String expectedToolbarTitle = "shopping bag" + mToolbarTitleSuffix;
onView(withTextIgnoreCase(expectedToolbarTitle)).check(matches(isDisplayed()));
}
}
Its parent class:
@RunWith(AndroidJUnit4.class)
public class MyActivityTest {
@Rule
public MyActivityTestRule<DeepLinkActivity> activityTestRule;
protected String mToolbarTitleSuffix;
@Before
public void prepare() {
if (!BuildConfig.FLAVOR.equals(ENV_PRODUCTION)) {
mToolbarTitleSuffix = String.format(" (%s)", BuildConfig.FLAVOR);
}
}
@After
public void resetCountry() {
if (activityTestRule != null) {
PrefUtils.clear(InstrumentationRegistry.getTargetContext());
PrefUtils.setCurrentCountryCode(activityTestRule.getmCurCountryCode());
PrefUtils.setCurrentLangCode(activityTestRule.getmCurLangCode());
}
}
protected void setUpWait() {
try {
Thread.sleep(3 * 1000);
} catch (InterruptedException e) {
Logger.e(e, "");
}
IdlingPolicies.setMasterPolicyTimeout(10, TimeUnit.SECONDS);
IdlingPolicies.setIdlingResourceTimeout(5, TimeUnit.SECONDS);
}
}
MyActivityTestRule:
public class MyActivityTestRule<D extends Activity> extends ActivityTestRule {
private String mCurCountryCode;
private String mCurLangCode;
protected MyActivityTestRule(Class activityClass) {
super(activityClass);
}
public MyActivityTestRule(Class activityClass, boolean initialTouchMode) {
super(activityClass, initialTouchMode);
}
public MyActivityTestRule(Class activityClass, boolean initialTouchMode, boolean launchActivity) {
super(activityClass, initialTouchMode, launchActivity);
}
@Override
protected void beforeActivityLaunched() {
super.beforeActivityLaunched();
PrefUtils.setup(InstrumentationRegistry.getTargetContext());
mCurCountryCode = PrefUtils.getCurrentCountryCode();
mCurLangCode = PrefUtils.getCurrentLangCode();
PrefUtils.clear(InstrumentationRegistry.getTargetContext());
PrefUtils.setCurrentCountryCode("SG");
PrefUtils.setCurrentLangCode("en");
}
String getmCurCountryCode() {
return mCurCountryCode;
}
String getmCurLangCode() {
return mCurLangCode;
}
}