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?

0

2 Answers 2

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

6
  • Is Firebase's test lab exactly like Google Pre-Launch report?
    – Avamander
    Jul 13, 2017 at 13:49
  • Pretty sure but haven't tested it myself. I will be testing this code in production shortly. I'll report back...
    – Ryan R
    Jul 13, 2017 at 21:30
  • 7
    I tested this and it detects the test device.
    – Ryan R
    Jul 14, 2017 at 15:38
  • 2
    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'.
    – xarlymg89
    Jun 20, 2019 at 15:39
  • @xarlymg89 did you find a solution to avoid first_open and etc under test runs?
    – serein
    Sep 18, 2019 at 19:23
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.