0

On the Play Store and on Firebase Test Lab I can run automated tests without writing any scripts, they just go through the app and try stuff for a few minutes.

How can I run this kind of test either from the command line or from Android Studio? I have about 10 different phones I would like to run it on.

Thanks.

Edit: just to be clear, I'm asking about the automatic robot test, where I don't tell it anything, it just tries stuff.

casolorz
  • 8,486
  • 19
  • 93
  • 200
  • Create UI tests with Espresso Test Recorder Click Run > Record Espresso Test. In the Select Deployment Target window, choose the device on which you want to record the test. If necessary, create a new Android Virtual Device. Click OK. – Jaspalsinh Gohil Oct 30 '19 at 12:23
  • But I don't have to do that for Firebase or the Play Store Console, it is like an automatic robot that just tries stuff. I want that automatic robot or is that something Google has made for themselves? – casolorz Oct 30 '19 at 14:53

1 Answers1

3

There are 2 options :

  1. You can record Robo tests through Android Studio. Crawler is part of Jetpack https://developer.android.com/training/testing/crawler

  2. You can run Monkey tests through command line. Monkey is part https://developer.android.com/studio/test/monkey

Dinesh
  • 948
  • 6
  • 11
  • That monkey test looks like what I want, but I'm guessing they have fine tuned it because I don't seem to get as much activity from it when I run it, but I'm still playing with all the options. Thanks. – casolorz Oct 30 '19 at 18:31
  • You can actually configure all possible sort of events. Like % of click events, % of swipe events etc. – Dinesh Oct 30 '19 at 18:33
  • @casolorz Firebase Test Lab also uses crawler – Zohaib Amir Nov 01 '19 at 13:05
  • @ZohaibAmir Do you mind explaining a bit further how to use crawler? I looked at their site, downloaded the app, and it runs the crawler apk on my phone but never even opens my app then says it found 0 crashes. I'm launching my installed package. If I launch the apk it says `androidx.test.tools.crawler.launcher.exceptions.AppPackageNameExtractionException: Failed to extract a package name for APK`. Thanks. – casolorz Nov 01 '19 at 19:41
  • @casolorz After downloading the jar file, you need to run following command after connecting device: `java -jar crawl_launcher.jar --app-package-name PACKAGE --android-sdk path/to/my/android/sdk` Don't forget to replace the package name and path to sdk – Zohaib Amir Nov 01 '19 at 19:55
  • 1
    Yeah that is what I'm running plus the device serial param and it opens the crawler on my phone but never opens my app. Do I need something inside my app for this to work? – casolorz Nov 01 '19 at 20:18
  • The documentation says , "Specifies the package name of your app. Use this option when your app is already installed on the device and no re-installation is required. This is a required flag if --apk-file isn't specified. " Does that ring a bell? – Dinesh Nov 02 '19 at 02:48
  • 3
    Same as @casolorz, it did not work to me as well. I've followed the instructions (use existing app and my own app), but the crawler did not work as intented. Looking at the logs, I could see the message:"Permission Denial: starting instrumentation ComponentInfo{androidx.test.tools.crawler/androidx.test.runner.AndroidJUnitRunner} from pid=25919, uid=25919 not allowed because package androidx.test.tools.crawler does not have a signature matching the target br.com.sampleapp". However, my own does not have signature. – jupi Mar 04 '20 at 14:58
  • BTW, I've found an interesting link that provide more details about App Crawler: https://android.jlelse.eu/test-robo-scripts-locally-useful-for-firebase-test-lab-pre-launch-reports-41da83d5769f – jupi Mar 04 '20 at 15:08
  • How to run App Crawler: https://medium.com/@denysiakimov/how-to-run-android-app-crawler-testing-tool-a0d6f387e89e – tgk23 Jul 28 '21 at 03:39