Skip to content

Code Coverage Support for Patrol Flutter Tests on BrowserStack #2733

@iammofidul

Description

@iammofidul

Steps to reproduce




Build Test Suite APK
./gradlew app:assembleAndroidTest


Build APK
patrol build android --flavor flavor --dart-define=app_flavor=flavor --dart-define=app_environment=env

Upload APK

curl --location 'https://api-cloud.browserstack.com/app-automate/espresso/v2/app' \
--form 'file=@"file path"'


Upload test Suite APK
curl --location 'https://api-cloud.browserstack.com/app-automate/espresso/v2/test-suite' \
--form 'file=@"filePath"'



Run Test
curl --location 'https://api-cloud.browserstack.com/app-automate/espresso/v2/build' \
--data '{
    "singleRunnerInvocation": "true",
    "networkLogs": "true",
    "disableAnimations": "true",
    "deviceLogs": "true",
    "video": "true",
    "useOrchestrator": "true",
    "clearPackageData": "true",
    “coverage”:”true”,
    "app": "bs://Test",
    "testSuite": "bs://Test",
    "devices": [
      "Google Pixel 9-15.0"
    ],
    "project": "TEST APP",
    "buildTag": "Timestamp: $timestamp",
    "shards": {"numberOfShards": 3}
  }'




API to fetch Report
curl --location 'https://api-cloud.browserstack.com/app-automate/espresso/v2/builds/BuildId' \


Coverage API
curl --location 'https://api-cloud.browserstack.com/app-automate/espresso/v2/builds/buildId/sessions/sessionId/coverage' \







Actual results

Result 
<?xml version="1.0" encoding="UTF-8"?>
<Error>
    <Code>NoSuchKey</Code>
    <Message>The specified key does not exist.</Message>
    <Key>Buildid/sessionId/espresso_session_coverage_Id</Key>
    <RequestId>Id</RequestId>
    <HostId>Id</HostId>
</Error>

Logs

Logs
NA

Patrol version

patrol: 3.15.1

Patrol Doctor output

Patrol Doctor output
Patrol doctor:
Patrol CLI version: 3.5.1
Flutter command: flutter 
  Flutter 3.27.4 • channel [user-branch]
Android: 
• Program adb found in /Users/username/Library/Android/sdk/platform-tools/adb
• Env var $ANDROID_HOME set to /Users/username/Library/Android/sdk
iOS / macOS: 
• Program xcodebuild found in /usr/bin/xcodebuild
• Program ideviceinstaller found in /opt/homebrew/bin/ideviceinstaller

Flutter Doctor output

Flutter Doctor output
<!--Doctor summary (to see all details, run flutter doctor -v):
[!] Flutter (Channel [user-branch], 3.27.4, on macOS 15.6 24G84 darwin-arm64, locale en-IN)
    ! Flutter version 3.27.4 on channel [user-branch] at /Users/mofidulislam/development/flutter
      Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
      If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/setup.
    ! Upstream repository unknown source is not a standard remote.
      Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss this error.
[!] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/to/macos-android-setup for more details.
[!] Xcode - develop for iOS and macOS
    ✗ Xcode installation is incomplete; a full installation is necessary for iOS and macOS development.
      Download at: https://developer.apple.com/xcode/
      Or install Xcode via the App Store.
      Once installed, run:
        sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
        sudo xcodebuild -runFirstLaunch
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.1)
[✓] VS Code (version 1.103.0)
[✓] Connected device (3 available)
[✓] Network resources

-->

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions