How to detect running in Firebase Test Lab

Your 'device under test' should check the IP address and disable analytics if in the Firebase Test Lab IP range.

See my answer at https://stackoverflow.com/a/54954273/114549 for a Util method that handles this.


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
}