如何在 Firebase 测试实验室中检测 运行
How to detect running in Firebase Test Lab
我最近发现我的应用程序在 Firebase 中的设置存在问题。我们配置了预发布报告,这意味着测试实验室设备正在为我们的分析贡献大量匿名会话。
有什么方法可以检测到某个设备是 运行 这些测试吗?例如,isUserAMonkey or isRunningInTestHarness return 是否适用于测试实验室中的测试?如果是这样,这将允许我调整我的 analytics/etc 的配置。
这实际上是mentioned in the docs。
您可以检查名为“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
}
您的 'device under test' 应该检查 IP 地址,如果在 Firebase 测试实验室 IP 范围内则禁用分析。
请参阅我在 的回答,了解处理此问题的 Util 方法。
我最近发现我的应用程序在 Firebase 中的设置存在问题。我们配置了预发布报告,这意味着测试实验室设备正在为我们的分析贡献大量匿名会话。
有什么方法可以检测到某个设备是 运行 这些测试吗?例如,isUserAMonkey or isRunningInTestHarness return 是否适用于测试实验室中的测试?如果是这样,这将允许我调整我的 analytics/etc 的配置。
这实际上是mentioned in the docs。
您可以检查名为“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
}
您的 'device under test' 应该检查 IP 地址,如果在 Firebase 测试实验室 IP 范围内则禁用分析。
请参阅我在