Skip to main content
LambdaTest App Test Automation is a cloud-based testing platform that provides access to real Android and iOS devices. This guide shows you how to run Patrol tests on LambdaTest.
This integration is currently Android-only. iOS support is not yet available.

Overview

LambdaTest App Test Automation enables you to run your Patrol tests on real Android devices in the cloud. The platform offers over 3000+ real devices and browsers for comprehensive testing.

Prerequisites

1

Create LambdaTest account

Sign up for a LambdaTest account if you don’t have one.
2

Get your credentials

Find your username and access key in your LambdaTest Profile.
3

Set environment variables

Export your credentials as environment variables:
export LT_USERNAME="your_username"
export LT_ACCESS_KEY="your_access_key"
Add these to your shell profile to persist them:
echo 'export LT_USERNAME="your_username"' >> ~/.zshrc
echo 'export LT_ACCESS_KEY="your_access_key"' >> ~/.zshrc
source ~/.zshrc

Setup for Android

1

Update test runner

Modify your app-level build.gradle file to use the LambdaTest-specific test runner:
android {
  // ...
  defaultConfig {
    // ...
    testInstrumentationRunner "pl.leancode.patrol.LambdaTestPatrolJUnitRunner"
  }
  // ...
}
The LambdaTestPatrolJUnitRunner is a specialized test runner that integrates with LambdaTest’s infrastructure and ensures proper test execution on their platform.
2

Sync Gradle

After making this change, sync your Gradle files:
cd android && ./gradlew --refresh-dependencies

Running Tests

Follow these steps to run your Patrol tests on LambdaTest:
1

Build APKs

Build your app and test instrumentation APKs using Patrol:
patrol build android --target integration_test/example_test.dart
This creates:
  • build/app/outputs/apk/debug/app-debug.apk (app under test)
  • build/app/outputs/apk/androidTest/debug/app-debug-androidTest.apk (test suite)
You can target multiple test files by separating them with commas:
patrol build android --target integration_test/app_test.dart,integration_test/login_test.dart
2

Upload app to LambdaTest

Upload your app APK to LambdaTest using their REST API:
curl -u "$LT_USERNAME:$LT_ACCESS_KEY" \
  -X POST "https://manual-api.lambdatest.com/app/upload/realDevice" \
  -F "appFile=@build/app/outputs/apk/debug/app-debug.apk" \
  -F "name=app-debug.apk"
The response will contain an app_url like lt://APP1016047291733313441063634. Save this for the next steps.
See LambdaTest’s documentation for more details.
3

Upload test suite to LambdaTest

Upload your test instrumentation APK:
curl -u "$LT_USERNAME:$LT_ACCESS_KEY" \
  -X POST "https://manual-api.lambdatest.com/app/upload/realDevice" \
  -F "appFile=@build/app/outputs/apk/androidTest/debug/app-debug-androidTest.apk" \
  -F "name=app-debug-androidTest.apk"
The response will contain a test_suite_url like lt://APP1016047291733312896265135. Save this for execution.
See LambdaTest’s documentation for more details.
4

Execute tests

Start the test execution by making a POST request with your test configuration:
curl -u "$LT_USERNAME:$LT_ACCESS_KEY" \
  -X POST "https://mobile-api.lambdatest.com/framework/v1/espresso/build" \
  -H "Content-Type: application/json" \
  -d '{
    "app": "lt://APP1016047291733313441063634",
    "testSuite": "lt://APP1016047291733312896265135",
    "device": ["Pixel 7 Pro-13"],
    "queueTimeout": 600,
    "deviceLog": true,
    "network": true,
    "build": "Patrol Test Build"
  }'
Configuration options:
  • app - The app URL from step 2
  • testSuite - The test suite URL from step 3
  • device - Array of device configurations (format: “DeviceName-OSVersion”)
  • queueTimeout - Maximum time to wait for device availability (seconds)
  • deviceLog - Capture device logs during test execution
  • network - Capture network logs
  • build - Build name to organize tests in dashboard
See LambdaTest’s documentation for all available options.

Example Execution

Here’s a complete example of a successful test execution:
$ export LAMBDATEST_PROJECT=AwesomeApp
$ export LAMBDATEST_DEVICES='["Pixel 7 Pro-13"]'
$ patrol build android --target integration_test/app_test.dart
 Building apk with entrypoint test_bundle.dart...
 Completed building apk with entrypoint test_bundle.dart (11.0s)

$ # Upload app
$ curl -u "$LT_USERNAME:$LT_ACCESS_KEY" \
  -X POST "https://manual-api.lambdatest.com/app/upload/realDevice" \
  -F "appFile=@build/app/outputs/apk/debug/app-debug.apk" \
  -F "name=app-debug.apk"
Uploaded app, "app_id": "lt://APP1016047291733313441063634"

$ # Upload test suite
$ curl -u "$LT_USERNAME:$LT_ACCESS_KEY" \
  -X POST "https://manual-api.lambdatest.com/app/upload/realDevice" \
  -F "appFile=@build/app/outputs/apk/androidTest/debug/app-debug-androidTest.apk" \
  -F "name=app-debug-androidTest.apk"
Uploaded testsuite, "app_id": "lt://APP1016047291733312896265135"

$ # Execute tests
$ curl -u "$LT_USERNAME:$LT_ACCESS_KEY" \
  -X POST "https://mobile-api.lambdatest.com/framework/v1/espresso/build" \
  -H "Content-Type: application/json" \
  -d '{"app": "lt://APP1016047291733313441063634", "testSuite": "lt://APP1016047291733312896265135", "device": ["Pixel 7 Pro-13"]}'
{
  "status": ["Success"],
  "buildId": ["5875687"],
  "message": [""]
}

Viewing Results

After starting a test execution, you can:
  1. View in Dashboard: Go to the LambdaTest App Automation Dashboard to see live test execution
  2. Access Logs: View device logs, network logs, and screenshots
  3. Download Videos: Download video recordings of test execution
  4. Check Status via API: Use the buildId to query test status
curl -u "$LT_USERNAME:$LT_ACCESS_KEY" \
  "https://mobile-api.lambdatest.com/framework/v1/espresso/build/5875687"

Available Devices

LambdaTest offers a wide range of Android devices. Popular configurations include:
To see all available devices:
  1. Visit the LambdaTest Automation Capabilities Generator
  2. Select “App Automation” and “Espresso”
  3. Browse available devices and generate configuration

Configuration Options

Customize your test execution with these configuration options:
Run tests on multiple devices in parallel:
{
  "app": "lt://APP123...",
  "testSuite": "lt://APP456...",
  "device": [
    "Pixel 7 Pro-13",
    "Samsung Galaxy S23-13",
    "OnePlus 11-13"
  ],
  "build": "Multi-device test"
}
Test location-based features:
{
  "app": "lt://APP123...",
  "testSuite": "lt://APP456...",
  "device": ["Pixel 7 Pro-13"],
  "geoLocation": "US"
}
Test under different network conditions:
{
  "app": "lt://APP123...",
  "testSuite": "lt://APP456...",
  "device": ["Pixel 7 Pro-13"],
  "networkProfile": "3G"
}
Available profiles: 4G, 3G, 2G, offline
Configure timeouts for your tests:
{
  "app": "lt://APP123...",
  "testSuite": "lt://APP456...",
  "device": ["Pixel 7 Pro-13"],
  "queueTimeout": 600,
  "idleTimeout": 120
}
  • queueTimeout - Max wait time for device availability (seconds)
  • idleTimeout - Max idle time before test is terminated (seconds)

Best Practices

Enable Device Logs

Always set deviceLog: true to capture detailed logs for debugging failures.

Use Build Names

Organize tests with meaningful build names to track test runs over time.

Test on Real Devices

Use real devices instead of emulators for more accurate test results.

Set Reasonable Timeouts

Configure queueTimeout and idleTimeout based on your test duration.

CI/CD Integration

Integrate LambdaTest into your CI/CD pipeline:
name: LambdaTest Tests

on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      
      - name: Setup Flutter
        uses: subosito/flutter-action@v2
        
      - name: Build APKs
        run: patrol build android --target integration_test/app_test.dart
        
      - name: Upload and run tests
        env:
          LT_USERNAME: ${{ secrets.LT_USERNAME }}
          LT_ACCESS_KEY: ${{ secrets.LT_ACCESS_KEY }}
        run: |
          # Upload app
          APP_RESPONSE=$(curl -u "$LT_USERNAME:$LT_ACCESS_KEY" \
            -X POST "https://manual-api.lambdatest.com/app/upload/realDevice" \
            -F "appFile=@build/app/outputs/apk/debug/app-debug.apk" \
            -F "name=app-debug.apk")
          APP_URL=$(echo $APP_RESPONSE | jq -r '.app_url')
          
          # Upload test suite
          TEST_RESPONSE=$(curl -u "$LT_USERNAME:$LT_ACCESS_KEY" \
            -X POST "https://manual-api.lambdatest.com/app/upload/realDevice" \
            -F "appFile=@build/app/outputs/apk/androidTest/debug/app-debug-androidTest.apk" \
            -F "name=app-debug-androidTest.apk")
          TEST_URL=$(echo $TEST_RESPONSE | jq -r '.app_url')
          
          # Execute tests
          curl -u "$LT_USERNAME:$LT_ACCESS_KEY" \
            -X POST "https://mobile-api.lambdatest.com/framework/v1/espresso/build" \
            -H "Content-Type: application/json" \
            -d "{ \"app\": \"$APP_URL\", \"testSuite\": \"$TEST_URL\", \"device\": [\"Pixel 7 Pro-13\"], \"build\": \"${{ github.run_number }}\" }"

Troubleshooting

Verify your credentials:
echo "Username: $LT_USERNAME"
echo "Access Key: ${LT_ACCESS_KEY:0:5}..."
Make sure there are no extra spaces or special characters. Get fresh credentials from your LambdaTest profile.
Common upload issues:
  • File not found: Verify the APK path is correct
  • File too large: LambdaTest has file size limits (typically 1GB)
  • Invalid APK: Ensure the APK was built successfully
Test with a simple curl command:
curl -u "$LT_USERNAME:$LT_ACCESS_KEY" \
  "https://mobile-api.lambdatest.com/framework/v1/espresso/builds"
If the device is busy or unavailable:
  • Check the device list for correct device names
  • Try a different device or wait and retry
  • Increase queueTimeout to wait longer for device availability
  • Verify your LambdaTest plan includes the requested device
If tests are uploaded but don’t execute:
  • Verify you’re using LambdaTestPatrolJUnitRunner in your build.gradle
  • Check that both app and test suite URLs are correct
  • Review the LambdaTest dashboard for error messages
  • Ensure the test APK is properly built with patrol build

Next Steps

BrowserStack

Compare with BrowserStack App Automate

Firebase Test Lab

Explore Google’s Firebase Test Lab

Resources

Build docs developers (and LLMs) love