How to detect if the app is running on Google Play Pre-Launch report devices?
Asked Answered
P

2

20

As I upload a new version of my app to Google Play I get a Pre-Launch testing report that's pretty nice and fine, but the issue is that most of the time the AI just wanders around the setup and does not test the actual UI. I'd like to pre-complete the setup quickly and randomly for those devices.

So my question is, is there a way to detect that it's running on those test devices?

Passionless answered 14/3, 2017 at 22:6 Comment(0)
S
21

You can detect a pre-launch test device with the following:

private boolean isTestDevice() {  
  String testLabSetting = Settings.System.getString(getContentResolver(), "firebase.test.lab");
  return "true".equals(testLabSetting);
}

See: https://firebase.google.com/docs/test-lab/android/android-studio#modify_instrumented_test_behavior_for

Shields answered 13/7, 2017 at 1:32 Comment(7)
Is Firebase's test lab exactly like Google Pre-Launch report?Passionless
Pretty sure but haven't tested it myself. I will be testing this code in production shortly. I'll report back...Shields
I tested this and it detects the test device.Shields
It definitely works, although, I have found out that Firebase Analytics will still record the first_open, screen_view and session_start events. From there on, the tests will stop working. Would there be any way of preventing this from happening? It's making my Firebase reports 'dirty'.Choric
@Choric did you find a solution to avoid first_open and etc under test runs?Volkan
@Volkan sadly not. I was testing other analytics tools, like the one from Microsoft. But haven't invested much more time in this matter. Lately I'm not sending too many APKs to the Play Console, so it's not a priority for me. But it'll certainly be great to fix this, in my opinion, misbehaviour.Choric
As of 2023 this no longer seems to work. Works for Firebase but not for the pre-launch reports. Anyone have a different solution?Euripides
A
3

In case anyone gets here looking for how to do this with React Native, check out the react-native-firebase package utils().isRunningInTestLab: https://rnfirebase.io/app/utils#test-lab.

Atc answered 12/4, 2021 at 20:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.