Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect running in Firebase Test Lab

I've discovered a problem recently with my app's setup in Firebase. We have the pre-launch report configured, which means that the test lab devices are contributing a large number of anonymous sessions to our analytics.

Is there any way to detect that a device is running these tests? For example, will isUserAMonkey or isRunningInTestHarness return true for tests in the test lab? This would allow me to adjust the configuration of my analytics/etc if so.

like image 554
tmtrademark Avatar asked Apr 24 '17 21:04

tmtrademark


1 Answers

This is actually mentioned in the docs.

You can check for the existence of a system property called "firebase.test.lab":

@Nullable String testLabSetting =
  Settings.System.getString(context.getContentResolver(), "firebase.test.lab");
if ("true".equals(testLabSetting)) {
  // Do something when running in Test Lab
}
like image 60
Doug Stevenson Avatar answered Sep 24 '22 15:09

Doug Stevenson