Table of Contents
APP AUTOMATE API

Sessions

Each executed build is composed of one or more test sessions. By default, each session is the execution of your test-suite on a single device. Thus, each device in the build will have a single test session. However, if sharding is used, each session is the execution of a single shard on a single device. Thus, each device in the build will have multiple sessions (one for each shard).

Each session has a unique identifier (session ID) associated with it. This can be obtained using our Get build status endpoint. Using this session ID, you can use our REST API to access its test execution details including test results and debugging information for each individual test case.

Get session details

GET /app-automate/espresso/v2/builds/{buildID}/sessions/{sessionID}

Fetch status and test execution details for a given test session. You can access test results as well as debugging information such as instrumentation logs, device logs, network logs etc for individual test cases.

Request parameters

Request

curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X GET "https://api-cloud.browserstack.com/app-automate/espresso/v2/builds/57dd68e05f76ca3c9c0d4600fd78ae064fa537bb/sessions/c9215a31aace1d2b885f1c7a9f5d73bce55b4543"
  • buildID* String

    Build ID of the test session.

  • sessionID* String

    Session ID.

Response attributes 200 application/json

Response

{
    "id": "c9215a31aace1d2b885f1c7a9f5d73bce55b4543",
    "status": "failed",
    "start_time": "2020-06-04 07:44:20 +0000",
    "duration": 43,
    "testcases": {
        "count": 6,
        "status": {
            "passed": 0,
            "failed": 6,
            "skipped": 0,
            "timedout": 0,
            "error": 0,
            "running": 0,
            "queued": 0
        },
        "data": [
            {
                "class": "EnsureOperationTests",
                "testcases": [
                    {
                        "name": "ensureMultiplicationWorks",
                        "start_time": "2020-06-04 07:44:25 +0000",
                        "status": "failed",
                        "duration": "2.057",
                        "video": "https://api.browserstack.com/app-automate/espresso/builds/57cc68e05f76ca3c9c0d4600fd78ae064fa537bb/sessions/tests/c9215a31aace1d2b885f1c7a9f5d73bce55b4543406d4de4/video#t=0,5",
                        "id": "c9215a31aace1d2b885f1c7a9f5d73bce55b4543406d4de4",
                        "instrumentation_log": "https://api.browserstack.com/app-automate/espresso/builds/57cc68e05f76ca3c9c0d4600fd78ae064fa537bb/sessions/tests/c9215a31aace1d2b885f1c7a9f5d73bce55b4543406d4de4/instrumentationlogs"
                    },
                    {
                        "name": "ensureDivisionWorks",
                        "start_time": "2020-06-04 07:44:31 +0000",
                        "status": "failed",
                        "duration": "1.96",
                        "video": "https://api.browserstack.com/app-automate/espresso/builds/57cc68e05f76ca3c9c0d4600fd78ae064fa537bb/sessions/tests/c9215a31aace1d2b885f1c7a9f5d73bce55b4543e5295377/video#t=6,11",
                        "id": "c9215a31aace1d2b885f1c7a9f5d73bce55b4543e5295377",
                        "instrumentation_log": "https://api.browserstack.com/app-automate/espresso/builds/57cc68e05f76ca3c9c0d4600fd78ae064fa537bb/sessions/tests/c9215a31aace1d2b885f1c7a9f5d73bce55b4543e5295377/instrumentationlogs"
                    }
                ]
            },
            {
                "class": "EnsureInputTests",
                "testcases": [
                    {
                        "name": "ensureMultipleInputIsHandled",
                        "start_time": "2020-06-04 07:44:50 +0000",
                        "status": "failed",
                        "duration": "0.313",
                        "video": "https://api.browserstack.com/app-automate/espresso/builds/57cc68e05f76ca3c9c0d4600fd78ae064fa537bb/sessions/tests/c9219a12aace1d2b885f1c7a9f5d73bce55b454324e815c7/video#t=25,28",
                        "id": "c9219a12aace1d2b885f1c7a9f5d73bce55b454324e815c7",
                        "instrumentation_log": "https://api.browserstack.com/app-automate/espresso/builds/57cc68e05f76ca3c9c0d4600fd78ae064fa537bb/sessions/tests/c9219a12aace1d2b885f1c7a9f5d73bce55b454324e815c7/instrumentationlogs"
                    }
                ]
            }
        ]
    },
}
  • id String

    Sesssion ID.
    Example: 5c5ab4338cec13aeb78f7a6977344556ac00bccd6

  • status String

  • start_time String

    Timestamp for starting test session execution.

  • duration String

    Total duration for test session execution.

  • testcases Object

    Details about each test-case execution for this session.

    SHOW VALUES
    • count Integer

      The total number of test cases in the session

    • status Object

      Count of test cases for each status type.s

      SHOW VALUES
      • passed Integer

        Total count of test cases with explicit test assertions that marks the test as passed.

      • failed Integer

        Total count of test cases with uncaught exceptions or explicit test assertions that marks test as failed.

      • skipped Integer

        Total count of test cases that never got executed by the test runner.

      • timedout Integer

        Total count of test cases that got timed-out.

      • error Integer

        Total count of test cases that errored due to an unanticipated issue on BrowserStack.

      • running Integer

        Total count of test cases that are currently under execution.

      • queued Integer

        Total count of test cases that are queued for execution.

    • data Array

      Details about test-case execution.

      SHOW VALUES
      • class String

        Name of the class containing the test cases.

      • testcases Array

        List of all the test cases belonging to given class and their test execution details.

        SHOW VALUES
        • name String

          Name of test case

        • start_time String

          Timestamp at which test execution was started.

        • status String

          Status of test case execution in the given device or session. Different values for test case status:

          Key Value
          passed Explicit assertion in the test case that marks the test as passed.
          failed Explicit assertion in the test case that marks the test as failed. This can also happen if there is an uncaught runtime exception during test execution.
          skipped A test case that was never invoked during the test-suite execution. It can happen in two different scenarios :
          (a) The session got timed out (by BrowserStack) because it exceeded 2 hour limit. All remaining test cases in the session will be marked as skipped.
          (b) Execution of a test case is skipped by the test runner. For e.g. This can happen if the test case uses an @Ignore annotation.
          timedout Execution of a test case (in a running state) is halted either because :
          (a) The session got timed out (by BrowserStack) because it exceeded 2 hour limit
          (b) The test case was idle for 15 mins (Idle is defined as no update from the test runner)
          error An errored test is one that failed due to an unanticipated issue on BrowserStack testing infrastructure.
          running Test case that is being executed by the test runner.
          queued Test case queued for execution. This is the default initial state.
        • duration String

          Total duration of test case execution on the given device.

        • video String

          URL to fetch video logs for the test-case execution.

        • id String

          Unique ID for the test-case execution on the given device.

        • instrumentation_log String

          URL to fetch instrumentation logs for the test-case execution.

Get JUNIT report

GET /app-automate/espresso/v2/builds/{buildID}/sessions/{sessionID}/report

Fetch JUnit XML report for a given test session.

Request parameters

Request

curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X GET "https://api-cloud.browserstack.com/app-automate/espresso/v2/builds/57dd68e05f76ca3c9c0d4600fd78ae064fa537bb/sessions/c9215a31aace1d2b885f1c7a9f5d73bce55b4543/report"
  • buildID* String

    Build ID of the build to which the session belongs.

  • sessionID* String

    Session ID.

Response 200 text/xml

Response

<?xml version="1.0"?>
<testsuites>
    <testsuite name="com.sample.browserstack.samplecalculator.EnsureInputTests" tests="2" failures="2" skipped="0" timedout="0" errors="0" time="4.419" timestamp="2020-06-04 07:44:14 +0000">
        <properties>
            <property session_id="c9215a31aace1d2b885f1c7a9f5d73bce55b4543"/>
            <property devicename="Google Pixel 3"/>
            <property os="Android"/>
            <property version="9"/>
        </properties>
        <testcase name="ensureMultipleInputIsHandled" classname="com.sample.browserstack.samplecalculator.EnsureInputTests" result="failed" test_id="be2460f7f5fd21f73673060d4046199e6a94d9e624e815c7" time="0.422" video_url="https://www.browserstack.com/s3-upload/bs-video-logs-aps/s3-ap-south-1/be2460f7f5fd21f73673060d4046199e6a94d9e6/video-be2460f7f5fd21f73673060d4046199e6a94d9e6.mp4#t=0,3">
            <failure>java.lang.RuntimeException: Unable to capture screenshot.
          ... 32 more
            </failure>
        </testcase>
    </testsuite>
    <testsuite name="com.sample.browserstack.samplecalculator.EnsureOperationTests" tests="4" failures="4" skipped="0" timedout="0" errors="0" time="22.643" timestamp="2020-06-04 07:44:22 +0000">
        <properties>
            <property session_id="c9215a31aace1d2b885f1c7a9f5d73bce55b4543"/>
            <property devicename="Google Pixel 3"/>
            <property os="Android"/>
            <property version="9"/>
        </properties>
        <testcase name="ensureMultiplicationWorks" classname="com.sample.browserstack.samplecalculator.EnsureOperationTests" result="failed" test_id="be2460f7f5fd21f73673060d4046199e6a94d9e6406d4de4" time="2.366" video_url="https://www.browserstack.com/s3-upload/bs-video-logs-aps/s3-ap-south-1/be2460f7f5fd21f73673060d4046199e6a94d9e6/video-be2460f7f5fd21f73673060d4046199e6a94d9e6.mp4#t=8,13">
            <failure>java.lang.RuntimeException: Unable to capture screenshot.
          ... 32 more
            </failure>
        </testcase>
    <testsuite name="com.sample.browserstack.samplecalculator.ExampleInstrumentedTest" tests="1" failures="0" skipped="0" timedout="0" errors="0" time="0.009" timestamp="2020-06-04 07:45:01 +0000">
        <properties>
            <property session_id="c9215a31aace1d2b885f1c7a9f5d73bce55b4543"/>
            <property devicename="Google Pixel 3"/>
            <property os="Android"/>
            <property version="9"/>
        </properties>
        <testcase name="useAppContext" classname="com.sample.browserstack.samplecalculator.ExampleInstrumentedTest" result="passed" test_id="be2460f7f5fd21f73673060d4046199e6a94d9e65e747bcf" time="0.009" video_url="https://www.browserstack.com/s3-upload/bs-video-logs-aps/s3-ap-south-1/be2460f7f5fd21f73673060d4046199e6a94d9e6/video-be2460f7f5fd21f73673060d4046199e6a94d9e6.mp4#t=47,50"/>
    </testsuite>
</testsuites>

The response will be XML report comprising the details of each test-case execution in the session.

Get code coverage report

GET /app-automate/espresso/v2/builds/{buildID}/sessions/{sessionID}/coverage

Retrieve the Jacoco code coverage report for a given test session. In order to use the code coverage report, you need to ensure following:

  1. Your Android project uses Jacoco code coverage library
  2. Ensure testCoverageEnabled parameter set to true in your project’s build gradle file.
  3. The coverage parameter should be set to true while using the Execute a build.

Request parameters

Request

curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X GET "https://api-cloud.browserstack.com/app-automate/espresso/v2/builds/57dd68e05f76ca3c9c0d4600fd78ae064fa537bb/sessions/c9215a31aace1d2b885f1c7a9f5d73bce55b4543/coverage"
  • buildID* String

    Build ID of the build to which the session belongs.

  • sessionID* String

    Session ID.

Response 200 application/octet-stream

The response will be a binary code coverage report comprising the details of each test-case execution.

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