How to detect running in Firebase Test Lab

断了今生、忘了曾经 提交于 2019-12-08 19:49:46

问题


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.


回答1:


This is actually mentioned in the docs.

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

String testLabSetting =
  Settings.System.getString(context.getContentResolver(), "firebase.test.lab");
if ("true".equals(testLabSetting)) {
  // Do something when running in Test Lab
}



回答2:


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.



来源:https://stackoverflow.com/questions/43598250/how-to-detect-running-in-firebase-test-lab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!