Firebase Device Lab - how can I run cross app tests - android

I'm interested in running some UIAutomator tests in the Firebase Test Lab: One of our tests we want to do involves functionality in 2 different apps.
So our process locally is:
Install app A
Install app B
Install the intrumentation apk
Run the instruentation step.
However, with the gcloud commands, it looks like we can only upload 1 app apk and 1 test apk.
Is there a way to do multiple apk testing in the Test Lab?

Installing additional APKs is supported in gcloud beta:
gcloud beta firebase test android run \
--app=path/to/app1.apk \
--test=path/to/test.apk \
--additional-apks=path/to/app2.apk,path/to/app3.apk \
...other options here...
You might need to install the beta component with gcloud components install beta or the package manager of your OS distribution.

Related

Installing Prerequisite apps for testing our app in firebase Test Lab

How can we have another apps installed in devices that is used in testing process( robotests , ...) , before starting testing our app?
I mean my app needs some other apps to be installed in the device to work completely and correctly .
Is it possible?
i'm using firebase test lab
You cannot upload additional APKs via the Firebase web console, but you can interact with Test Lab by using the gcloud command-line app too.
The "beta" version of the gcloud command-line has an option to add additional APKs. If you run
gcloud beta firebase test android run --help
You will find the following option that allows you to install more apks:
--additional-apks=APK,[APK,...]
A list of up to 100 additional APKs to install, in addition to those
being directly tested. The path may be in the local filesystem or in
Google Cloud Storage using gs:// notation.
Here's an example on how you would use this to start a test:
gcloud beta firebase test android run \
--app=build/outputs/apk/debug/app-debug.apk \
--test=build/outputs/apk/androidTest/debug/app-debug-androidTest.apk \
--device model=walleye,version=28 \
--additional-apks=path/to/another.apk

Firebase test lab - Supply Robo script from CI or command line?

I am using Firebase test labs along with Jenkins to run a Robo test after each build of my Android app. Currently I use a Yaml file to setup all the configurations I need. I supply a username and password using the Robo Directives. However, I now want to supply a Robo Script that controls the sign in process a little bit more than just supplying the login details. I have made the script in Android studio, but I don't see anywhere in the documentation that allows me to supply the location of the Robo Script from the Yaml file or command line, does anyone know if this is possible?
I have tried the documentation and various links from here - https://firebase.google.com/docs/test-lab/command-line
This feature is available today in beta, but not as a full release. You can use the --robo-script flag to specify a script to upload when using
gcloud beta firebase test android run
It is not available in the release version:
gcloud firebase test android run
After some time in beta, new features will be promoted to full release. See the CLI docs for the beta version here.
I know this is an old question but I was looking for the same thing and I find it :
https://cloud.google.com/sdk/gcloud/reference/beta/firebase/test/android/run#--robo-script
Using like this
gcloud firebase test android run --app app-release.apk --robo-script script.json

Failed to start an instrument test from Firebase gcloud command line

I tried to test an app with Firebase Test lab but get an error saying "testOnly APKs are not allowed."
C:\temp>gcloud firebase test android run --type instrumentation --app myapp.apk --test myapp-androidTest.apk --device model=Nexus10,version=22,locale=en,orientation=landscape --timeout 300s
Have questions, feedback, or issues? Get support by visiting:
https://firebase.google.com/support/
Uploading [myapp.apk] to Firebase Test Lab...
Uploading [myapp-androidTest.apk] to Firebase Test Lab...
Raw results will be stored in your GCS bucket at [https://console.developers.google.com/storage/browser/test-lab-j9zwyqscmy0rw-k53tazzivjxvu/2017-10-16_11:56:43.691000_AcnJ/]
Test [matrix-1vxb29yr0b2z7] has been created in the Google Cloud.
Firebase Test Lab will execute your instrumentation test on 1 device(s).
Creating individual test executions...failed.
ERROR: (gcloud.firebase.test.android.run)
Matrix [matrix-1vxb29yr0b2z7] failed during validation: "testOnly" found in the Manifest. testOnly APKs are not allowed.
C:\temp>
But the firebase test works when I run it in Android Studio 3.0 RC1 by setting the deployment target options to "Firebase Test Lab Device Matrix".
I searched "testOnly" in my project but not found it. It looks like it was gradle injected the attribute into AndroidManifest.xml.
Does anyone know how to resolve it?
I have the same probllem. I finally resolved by generating the apk with 'Build > Build APK(s)'
The APk is generated at : app\build\outputs\apk\debug
The apk is generated witouth the 'testOnly' label and it runs on firebase.
I found this info on https://developer.android.com/studio/run/index.html
It was Android Studio added the field. Refer to the document developer.android.com/guide/topics/manifest/… "Android Studio automatically adds this attribute when you click Run". Not using Android Studio, I built an APK from the command line then I can upload it to Firebase Test Lab for testing.
When you use the instant run option and the APK generated in this fashion cannot be used for any kind of firebase test.
Instead select the build option above and then select the build APK option and the the APK generated in this fashion can be used for the firebase test.

Firebase Test lab CI upload apks

When setting up my buildserver to use Firebase Test Lab for espresso testing I keep running into the error.
ERROR: (gcloud.beta.test.android.run) Permission denied while fetching the default results bucket
(Error 403: Access Not Configured. Cloud Tool Results API has not been used in project CLOUD_PROJECT_ID before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/toolresults/overview?project=CLOUD_PROJECT_ID then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.).
Is billing enabled for project: [PROJECT_ID]?
When I try it on my own machine which is logged in via my own account, running the command below works correctly.
gcloud beta test android run \
--type instrumentation \
--app app-debug.apk \
--test app-debug-androidTest.apk \
--device-ids Nexus4,Nexus5 \
--os-version-ids 18,21,25 \
--locales en \
--orientations portrait
On my build server I want to use a service-account but when I execute the command I get the error mentioned earlier. Does anyone know what the correct way is to set this up? Does the service-account need some special role beside project editor?
In the build script I execute the commands below to authenticate and set the project before uploading the APK's
gcloud config set project PROJECT_ID
gcloud auth activate-service-account service-account#email.address --key-file ~/gcloud-service-key.json
Finally figured it out. If you want to use service accounts for Firebase Test Lab you have to enable Cloud Tool Results API which can only be enabled through Google Cloud Console and not the Firebase Console.
Also, you're probably using it from a CI/CD server and using Service Accounts for authentication... Don't do as I did, don't use a google cloud platform service account. Instead, use a Firebase Service Accounts json key from here
https://console.firebase.google.com/u/0/project/YOUR_PROJECT_ID/settings/serviceaccounts/

Android Jenkins Deployment

I am looking at ways to automate Android build deployment for Beta/QA Testers via Jenkins. Are there any solutions out there that will allow me to deploy my android apk via jenkins to a test harness of some sort, from where my QA and beta testers could download and install the application ?
Everything almost work out of the box for Android on Jenkins now. You can :
use the Android Emulator Plugin and perform your tests using ant debug test
get emma coverage and reporting (you must export the emma reports as artefacts) using ant emma installd test
you can even get your unit test reports inside jenkins (export the reports as artefacts as well) using a special test runner : either the missing Android Test Runner or Zutubi test runner.
you can get lint analysis and results thanks to the Lint Plugin for Jenkins as well.
Everything that can be done with ant will also work with maven for more industrial configurations.
We are actually working on a better integration of other testing technologies and a better intregration with Sonar, this topic should get some progress during 2013.
For distributing your APK to beta testers, you can try services like HockeyApp or Google Play alpha/beta distribution, both of which have Jenkins plugins to upload your builds.
By using those services and their SDKs in your app, you automatically get usage statistics and crash reports from your testers.

Categories

Resources