Skip to main content
Transform your testing process with: Real Device Features, Company-wide Licences, & App Percy
No Result Found
Get your setup working faster. Join our Discord for optimisation tips from elite testers. Join our DiscordJoin our Discord

Run your first automated multi-module app test using Espresso

Run your first multi-module app test using Espresso on BrowserStack App Automate. Access the test results on the App Automate dashboard or use our REST API.

Modularization is a software technique where an app is organized into loosely coupled, independent entities called modules. Each module can be tested separately and each module has its own main class or runner. Multi-module apps can be worked upon by multiple developers with less conflict. Modularity also helps in simplifying debugging and re-deployments.

Run your first multi-module app test

Multi-module app testing is different from the Espresso testing covered in the above sections. To run your first test for multi-module apps, use the following steps instead:

1. Setup

  1. You need a BrowserStack username and access key. To obtain your access credentials, sign up for a free trial or purchase a plan.

  2. Multi-module app APK and test suite APK are bundled together into a single .apk file.

Download the sample multi-module app from GitHub. Of the modules present, only detail, home, and local have Espresso tests. To build the module APK required for upload, enter the module folder and run gradle’s assembleAndroidTest task.

2. Upload your app and test suite

Upload your Android module build (.apk) to BrowserStack servers using a REST API request.

The following sample cURL command shows how to upload an 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 for the request is as follows:

{
    "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"
}

The value of the module_url parameter in the response is used to specify hash id of your module apk which has both your app and test suite when you run multi-module tests.

App upload takes a few seconds to about a minute, depending on the size of your app. Do not interrupt the curl command until you get the response back.

3. Execute multi-module app tests

After you upload your .apk file to BrowserStack servers, send an API request to start the test execution as shown in the following sample cURL request:

curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/espresso/v2/module-build" \
-d '{"testSuite": "bs://j3c874f21852ea50957a3fdc33f47514288c4ba4", "devices": ["Samsung Galaxy S9 Plus-9.0"]}' \
-H "Content-Type: application/json"

A sample response for the request is as follows:

{
    "message" : "Success",
    "build_id" : "4d2b4deb810af077d5aed98f479bfdd2e64f36c3"
}

The build_id is used to uniquely identify your build in App Automate.

4. View test results

After you start an Espresso test suite execution using the REST API, visit your App Automate dashboard to view your test results, debugging logs, and overall test details.

You can also use API requests to view test results.

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

Is this page helping you?

Yes
No

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!

Talk to an Expert
Download Copy Check Circle