Upload modules for Espresso multi-module testing
Upload modules to test using multi-module on BrowserStack App Automate.
To test your multi-module apps, upload the module, which bundles both your app and test suite together as a single .apk file, to BrowserStack. There are multiple ways to achieve this, described below.
Upload module from filesystem
To test your multi-module apps on BrowserStack, upload your module to BrowserStack servers. Upload an Android app and test suite bundled together (.apk file) from your local filesystem or CI/CD server to BrowserStack using the REST API.
Here is an example cURL request to upload an Android app:
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/espresso/v2/module-app" \
-F "file=@/path/to/app/file/application-module.apk"
A sample response to the above API request is shown below:
{
"module_name": "application-module.apk",
"module_url": "bs://c8ddcb5649a8280ca800075bfd8f151115bba6b3",
"module_id": "c8ddcb5649a8280ca800075bfd8f151115bba6b3",
"uploaded_at": "2020-05-05 14:52:54 UTC",
"expiry" : "2020-06-05 14:52:54 UTC",
"framework": "module"
}
Note the value of module_url in the API response, bs://c8ddcb5649a8280ca800075bfd8f151115bba6b3 in the above example. This value is used later to specify the testSuite for your multi-module test execution.
- App upload takes a few seconds to about a minute depending on the size of your app. Do not interrupt the
cURLcommand until you get the response back. - If you upload an unsigned version of the Android app, BrowserStack signs it with its certificates before installing it to its devices. When BrowserStack resigns the apps, your app’s integration with third-party libraries such as Google Firebase services, Google Maps SDK, and Facebook SDK may not work if you have restricted the use of API keys based on the SHA-1 certificate fingerprint of the app’s signing key. To avoid this issue, sign the APK with your own certificates before uploading the app to BrowserStack.
Upload module using public URL
Upload your multi-module app and test suite bundled together (.apk file) from a public URL to BrowserStack using the REST API. This approach is useful when the module is hosted on a remote server, for example an S3 bucket, and is downloadable via a publicly accessible URL.
Here is an example cURL request to upload an Android module using a public URL:
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/espresso/v2/module-app" \
-F "url=https://www.browserstack.com/app-automate/sample-modules/android/Calculator-module.apk"
A sample response to the above API request is shown below:
{
"module_name": "Calculator-module.apk",
"module_url": "bs://c8ddcb5649a8280ca800075bfd8f151115bba6b3",
"module_id": "c8ddcb5649a8280ca800075bfd8f151115bba6b3",
"uploaded_at": "2020-05-05 14:52:54 UTC",
"expiry" : "2020-06-05 14:52:54 UTC",
"framework": "module"
}
Note the value of module_url in the API response, bs://c8ddcb5649a8280ca800075bfd8f151115bba6b3 in the above example. This value is used later to specify the testSuite for your Espresso test execution.
- App upload takes a few seconds to about a minute depending on the size of your app. Do not interrupt the
cURLcommand until you get the response back. - If you upload an unsigned version of the Android app, BrowserStack signs it with its certificates before installing it to its devices. When BrowserStack resigns the apps, your app’s integration with third-party libraries such as Google Firebase services, Google Maps SDK, and Facebook SDK may not work if you have restricted the use of API keys based on the SHA-1 certificate fingerprint of the app’s signing key. To avoid this issue, sign the APK with your own certificates before uploading the app to BrowserStack.
Define custom ID for app
On every module upload, a new value for module_url is generated. Use this value to execute your multi-module tests with the latest build of the module.
If you want to use a constant value to specify the module and don’t want to modify your scripts after every build upload, you can define a custom ID for your module. Use the same custom ID every time you upload a new build of the module. Here is an example cURL request to upload an Android module with the custom ID defined as poc_app:
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/espresso/v2/module-app" \
-F "file=@/path/to/app/file/Application-module.apk" \
-F "custom_id=poc_app"
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/espresso/v2/module-app" \
-F "url=https://www.browserstack.com/app-automate/sample-apps/android/Application-module.apk" \
-F "custom_id=poc_app"
A sample response to the above API request is shown below:
{
"module_url":"bs://f7c874f21852ba57957a3fdc33f47514288c4ba4",
"custom_id":"poc_app"
}
While executing your Espresso tests, use the custom_id value, poc_app in the above example, to specify the testSuite. The test execution picks the last uploaded build corresponding to that custom ID.
- The use of
custom IDis optional. - The maximum character limit in the
custom_idparameter is 100 and the characters allowed are a-z, A-Z, 0-9, period(.), underscore(_), and hyphen(-). -
custom_idapplies only to the individual user who uploaded the app. Other users in the same Group ID cannot reference the app using only thecustom_id.
A sample request to execute the build using custom_id:
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/espresso/v2/module-build" \
-d '{"devices": ["Google Pixel 7-13.0"], "testSuite": "poc_app"}'
A sample response for the above request looks like below:
{
"message": "Success",
"build_id": "0299dd041483f149c71e6e7f1a0ff34378fac926"
}
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
Thank you for your valuable feedback!