Skip to main content
Transform your testing process with: Real Device Features, Company-wide Licences, & App Percy
No Result Found

Get started with multi-module app test

Modularization is a software techinique 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/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 will 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.

Note: You can download a sample multi-module app from here. 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 "<username>:<password>" \
-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.

Note: App upload will take 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 "<username>:<password>" \-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.

5. 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