Skip to main content

Espresso Testing On HyperExecute

This page outlines how to execute your Espresso tests on HyperExecute with YAML 0.2

Prerequisites

To run the Tests on HyperExecute from your Local System, you are required:

Step 1: Setup Your Test Suite

You can use your own project to configure and test it. For demo purposes, we are using the sample repository.

Sample repo

Download or Clone the code sample for the Espresso framework from the LambdaTest GitHub repository to run the tests on the HyperExecute.

Image View on GitHub

Step 2: Setup the CLI in your Test Suite

After cloning / downloading the sample repo, you need to setup the CLI and the environment variables.

Download the HyperExecute CLI

The CLI is used for triggering the tests on HyperExecute. It is recommend to download the CLI binary on the host system and keep it in the root directory of the suite to perform the tests on HyperExecute.

You can download the CLI for your desired platform from the below mentioned links:

PlatformHyperExecute CLI
Windowshttps://downloads.lambdatest.com/hyperexecute/windows/hyperexecute.exe
MacOShttps://downloads.lambdatest.com/hyperexecute/darwin/hyperexecute
Linuxhttps://downloads.lambdatest.com/hyperexecute/linux/hyperexecute

Setup Environment Variable

Now, you need to export your environment variables LT_USERNAME and LT_ACCESS_KEY that are available in the LambdaTest Profile page.

Run the below mentioned commands in your terminal to setup the CLI and the environment variables.

export LT_USERNAME="undefined"
export LT_ACCESS_KEY="undefined"

Step 3: Upload your Application

Upload your android application (.apk file) to the LambdaTest servers using our REST API. You need to provide your Username and AccessKey in the format Username:AccessKey in the cURL command for authentication.

info

Enter your local path of your android app instead of <YOUR_LOCAL_APP_PATH> in the below cURL command.

curl -u "undefined:undefined" -X POST "https://manual-api.lambdatest.com/app/upload/realDevice" -F "appFile=@"<YOUR_LOCAL_APP_PATH>"" -F "name="sampleApp""

Response of above cURL will be a JSON object containing the App ID of the format - <APP123456789012345678901234567> and will be used in the next step.

Step 4: Upload your Test Suite

Upload your test suite (.apk file) to the LambdaTest servers using our REST API by providing your Username and AccessKey in the format Username:AccessKey in the cURL command for authentication.

Here is an example cURL request to upload your app using our REST API:

info

Enter your local path of your test suite app instead of <YOUR_LOCAL_APP_PATH> in the below cURL command.

Step 5: Configure YAML in your Test Suite

Enter your <APP_ID> and <TEST_SUITE_ID> in the YAML file that you have fetched in the above step.

---
version: "0.2"
globalTimeout: 150
testSuiteTimeout: 150
testSuiteStep: 150

concurrency: 2

runson: android

autosplit: true

framework:
name: "android/espresso"
args:
buildName: "Espresso"
video: true
deviceLog: true

# You can use either the appId (lt://APP1234567) or provide the path of the application using appPath. Both examples are given below.
appPath: proverbial_android.apk
testSuitePath: proverbial_android_expressotest.apk
# We have used the appPath and testSuitePath here.

appId: lt://<APP_ID>
testSuiteAppId: lt://<TEST_SUITE_ID>
# We have used the appId and testSuiteAppID here.

deviceSelectionStrategy: all
devices: ["Galaxy.*", "Pixel.*"]

jobLabel: ['HYP', 'Espresso', 'Auto Sharding']

Step 6: Execute your Test Suite

NOTE : In case of MacOS, if you get a permission denied warning while executing CLI, simply run chmod u+x ./hyperexecute to allow permission. In case you get a security popup, allow it from your System PreferencesSecurity & PrivacyGeneral tab.

Run the below command in your terminal at the root folder of the project:

./hyperexecute --config <path_of_yaml_file>

OR use this command if you have not exported your username and access key in the step 2.

./hyperexecute --user <your_username> --key <your_access_key> --config <path_of_yaml_file>

Visit the HyperExecute Dashboard and check your Job status.

Troubleshoot Guide

If you are stumbling upon errors during Espresso test execution, then refer to the Espresso Troubleshoot guide for detailed explanations to your common errors.

Additional Details

Sharding

Sharding is a mobile test automation technique that distributes test cases across multiple real and virtual devices via parallel testing. It entails breaking down test suites into smaller subsets known as shards and running each shard concurrently on separate test execution environments.

There are two types of Sharding:

Manual Sharding

This feature enables users to manually specify shards along with their definitions, offering multiple strategies such as class, package, and more. By doing so, users can have greater flexibility and control over the sharding process.

Auto Sharding

The system intelligently determines the distribution of tests across devices, employing specific criteria to optimize the testing process.

tip
  • When Shards are added :

    • If you are using the deviceSelectorStrategy: all,then in that case all the specified shards will be executed on every device available.

    • If you are using the deviceSelectorStrategy: any, then in that case all the specified shards will be executed on just one device from the provided list.

  • When Shards are not added :

    • If you are using the deviceSelectorStrategy: all, then in that case the tests will be executed on all mentioned devices in .yaml based on the concurrency.

    • If you are using the deviceSelectorStrategy: any, then in that case all the specified tests will be executed on each device from the provided list, considering the concurrency setting.

Conclusion

By following the instructions in this documentation, you can seamlessly execute the Espresso tests on HyperExecute, leveraging its secure cloud infrastructure, advanced features, and optimized test execution workflow.