How do I build only one class of Espresso Instrument APK file? - android

I had read these documents from AWS, learning how to use Espresso testing on AWS.
Then, I made 3 different classes for different tests.
In this step, I selected only one ‘class’ in the Configuration setting,
and run it by right click, only this LaunchActivityTest class runs on my device.
But while I upload the app-alpha-debug-androidTest.apk to AWS Device Farm,
I found that all of my 3 testing class are build in this APK.
How do I build only one class of Espresso Instrument APK file?

Related

Firebase Test Lab rerun test with same uploaded APK

I working on developing Android Instrumentation Tests written in Espresso. As part of the effort, I am uploading and running in Firebase Test Lab using the Firebase Console. It would save me a lot of time if I didn't have to upload the App APK every time I want to re-run a test.
Does anybody know if Firebase Test Lab stores uploaded App and Test APKs so that a test can be re-run without requiring APKs to be uploaded again? Or an option in the Firebase Test Lab console to access an App APK that was previously uploaded?
I tried to use Firebase Storage but I can't access the files from Test Lab.
Maybe using Cloud SDK command line interface it best option since the test run will be automatically initiated once the APKs load?
Files (and APKs) that you pass to gcloud firebase test android run can be both from the local file system, as well as files stored in Google Cloud Storage. E.g. see the official documentation for the --app argument.
If you don't want to pass these files for every test invocation, upload them first to GCS with gsutil:
gsutil cp myapp.apk gs://my-bucket/myapp.apk
Then, use them for every test run:
gcloud firebase test android run --app gs://my-bucket/myapp.apk

Deploying Android app using Azure DevOps and editing APK for different environments

this is a conceptual/design question.
We have a Xamarin Forms apps and I'm creating a build and release pipeline for the Android version in Azure DevOps.
We have 4 environments in total, internal, RC, staging and production.
For each of those I have created a powershell pre-build script that changes some configuration xml files, the app icons (different colours for different environments) and even the app name and package name (this way we can have all 4 installed on one device and be able to test using the different servers)
Now I have a build in DevOps which runs the pre-build script to modify all those things, builds the project, signs the apk and publishes it. In my release pipeline, I cannot use this logic because I need to be able to deploy the different apps to their own test groups in App Center.
So I decided to split the build, it would just build and then the release pipeline would have stages - alpha would run the script and modify the app and sign it and put it for testing in an Alpha group, the Beta stage to beta etc...
However, this means I have to modify the .apk after it was produced using powershell. For example, the Android Manifest file's content doesn't look like XML anymore and has strange NUL, DLE and other symbols in it. It'd make my life harder.
Do I build all 4 packages in my Build pipeline with prepared packages for all environments? This would increase the time a lot so it's undesirable but it'd save me from having to edit APKs later...
What are best practices in these kind of situations, what are you able to suggest I do, change the way I do everything or what?

How do I run instrumented tests of a module without an accompanying app?

I have made a library project consisting of an Android module and no application. This module relies on Android-specific functionality.
How do I run these tests with Firebase?
It seems like Firebase requires an app apk and a test apk, while I only have a test apk (*-androidTest.apk). I normally run tests locally without issues using ./gradlew connectedCheck.

Firebase - Can't run tests against standalone test project

I'm investigating a cloud-based solution for our UIAutomator 2.0 testing needs, and I'm having quite a few issues with uploading APKs for our test project.
We have a stand-alone test project that exists separately from the main Android application project. The package for the project is in the format com.company.project and the package for the test project is com.company.project.test.
1) If I attempt to upload a test APK that has all the tests in androidTest (and the gradle uses androidTestCompile for dependencies), Firebase console complains that:
"Unable to find instrumentation package for com.company.project.test"
This is likely because our test project is standalone, and the tests actually live under com.company.project.test.test.
2) On the other hand, if I change the location of tests to java main folder in the project and change androidTestCompile to compile for the gradle dependencies, when I attempt to upload the test APK Firebase console complains again:
"We experienced an error while validating your APK. Please verify the APK is correct and upload again."
I can't get a single test running since I'm blocked both ways.
Anyone else attempt to use Firebase Test Lab with a similar project hierarchy? Help!
Finally figured it out. Don't even bother with the web UI, use the gcloud terminal to run your tests instead. It's WAY more customizable.
https://cloud.google.com/sdk/gcloud/reference/firebase/test/android/run
You can specify the --test-package to whatever your test package is, whether it's a standalone project or not.

Generate UIAutomator Test JAR for AWS Device Farm from Android Studio Gradle build

I would like to run Android UIAutomator Tests with AWS Device Farm. The Tests needs to be uploaded as a separate JAR to AWS. In Android Studio (1.4) UIAutomator Tests are part of the app project itself, so no dedicated JAR is generated.
How can I generate a JAR, that just contains the UIAutomator Tests and meets the requirements of AWS Device Farm?
You'll still be able to execute these tests using AWS Device Farm without converting them to a JAR.
On March 12, 2015, Google announced uiautomator 2.0. Without going into too much detail, the significant change made in this new version is that these tests are based on Android instrumentation (generated as APK files) instead of the previously used system of uiautomator 1.0 (generated as JAR files).
I would have to examine the gradle/build configuration further, but my guess is that you're using the new Android testing libraries and thus, using uiautomator 2.0. When you build a project such as this, it will generate two APK files, one for your application and another for your instrumentation tests.
When using AWS Device Farm, you'll want to take these two APK files and upload them using the INSTRUMENTATION test type. This test type works for all Instrumentation based frameworks/tools such as Espresso, uiautomator 2.0, and Robotium. The UIAUTOMATOR test type is specifically for older uiautomator 1.0 projects that still build and use JAR files for their test packages.

Categories

Resources