Espresso Support

Bitbar Testing has had Espresso support since its first versions. This guide shows how to setup Android Studio and Espresso v2.0. Same or similar setup should work also for Eclipse and Android SDk.

  1. Open the SDK Manager (under Tools -> Android -> SDK Manager):


  2. Ensure the Android Support Repository is installed. This can be found under Extras.


  3. Open build.gradle file (under file structure app/build.gradle) in text editor.

  4. Add the following piece of code inside dependencies:

    androidTestCompile ''
    androidTestCompile ''

    In addition, if the application under test uses functionalities from espresso-contrib, the following line needs to be added inside dependencies:

    androidTestCompile ''
  5. Configure the instrumentation runner with the testInstrumentationRunner parameter. The build.gradle file should look like this:

    defaultConfig {
      applicationId "com.example.bbexample.myapplication"
      minSdkVersion 15
      targetSdkVersion 26
      versionCode 1
      versionName "1.0"
      testInstrumentationRunner ""

More information about Espresso Resource can be found in.

The New Test Runner - AndroidJUnitRunner

The AndroidJUnitRunner is a new unbundled test runner for Android, which is part of the Android Support Test Library and can be downloaded via the Android Support Repository. The new runner contains all improvements of GoogleInstrumentationTestRunner and adds more features, such as:

  • JUnit4 support
  • Instrumentation Registry for accessing Instrumentation, Context and Bundle Arguments
  • Test Filters @SdkSuppress and @RequiresDevice
  • Test timeouts
  • Sharding of tests
  • RunListener support to hook into the test run lifecycle
  • Activity monitoring mechanism ActivityLifecycleMonitorRegistry

The User Guide for AndroidJUnitRunner can be found here.

How to use Espresso v2.0 tests at Bitbar Testing

To get the tested app running on Bitbar Testing using Espresso scripts some steps are needed.

Create Test Configuration

First, a test configuration in Android Studio needs to be created. Open Run -> Edit Configurations. Click ‘+’ button on the left-top corner to add new configuration as Android Tests. Give a name to test configuration (here ‘New Test Config’), select module (here ‘app’) and specify the instrumentation runner (here ‘’). The open ‘Run/Debug Configuration’ dialog should look this this:


Now, the environment should be properly configured to build instrumentation packages.

Build Project

Once the test project is configured, build it and upload into Bitbar Testing. Under test run creation, create a standard “Android” type project, upload the application and test APKs and select wanted device group.

Start Testing

Start test and test results will be ready in few minutes!