Gradle

Regardless of the fact if you are using Android Studio (with Gradle as the default build system), you may use Gradle with other development tools. Here are the basic steps and instructions on how to use the BitBar Gradle plugin to build an instant and seamless bridge between your development environment and our devices at BitBar Testing.

BitBar Gradle Plugin takes care of automatically uploading your latest builds to BitBar Testing.

Step 1 - Install and configure BitBar Testing Gradle plugin

The installation of any Gradle-compatible plugin is straightforward. There are two different gradle.build files - one specific for the Project and one for the Module. To make it easier to adopt these configurations for a variety of different projects, modify the Module specific gradle.build file.

The build.gradle file

This file can be further modified with different setups for BitBar Cloud, but the basic three required configurations are as follows:

apply plugin: 'testdroid'

Applying a plugin to the project allows the plugin to extend the project's capabilities. For example, this allows adding tasks to projects (compiling and uploading the latest APK to BitBar Cloud).

Next, one needs to configure the BitBar credentials and cloud setups. Set up the device group against which you want to run your APK in BitBar Testing. For example, MyTestDevices is a demo user specific device group (not available as a default device group) and includes eight pre-selected devices.

testdroid {
          authorization "OAUTH2" //optional "APIKEY"|"OAUTH2"(default)
          apiKey "********************************" //required if authorization "APIKEY"
          deviceGroup 'MyTestDevices'
          mode "FULL_RUN"
          }

Finally, set the dependency for classpath, and in this case, it should be com.testdroid:gradle:1.5.0. Our Gradle plugin naturally evolves, so make sure to check the latest version from here. For the dependency configuration, use the following line as part of the buildscript > dependencies:

buildscript {
    repositories {
        ...
    }
    dependencies {
                 classpath 'com.testdroid:gradle:1.5.0'
                 }
    }

That's it! Gradle build is now executable in BitBar against the defined device group.

Step 2 - Running tests on BitBar Testing devices

The above configuration uploads the specified application and possible instrumentation package into BitBar Testing, and the test run is launched using a device from the MyTestDevices group. There are additional options to control test run creation and execution below.

There are basically two quick ways to set an app (and an instrumentation app) up and running on BitBar Testing. It can either be done from the command line by going to a project-specific path (for example, /Users/vvhelppi/AndroidStudioProjects/MyApplication2) and executing the following command:

./gradlew testdroidUpload

or using the Android Studio's Gradle projects view and double-clicking testdroidUpload under Tasks (app > verification):

App setup

Now, the project will be compiled, all dependencies will be fetched (done only once the first time), and the app + possible instrumentation package will be uploaded to BitBar Testing. The run log should look something like this:

Run log

Step 3: All Done

Within BitBar Testing, all details of a test run, such as logs, screenshots, performance stats, and much more are conveniently shown in an easy-to-use UI.

Test run results

The example above shows a test run from an empty Android Studio app project on eight devices. The test execution time is minuscule as there isn't much logic in an empty app. Also, the App Crawler run targeted at this sort of app basically checks whether the app can be appropriately launched and stopped - and uses those as test cases.

Advanced configuration

Additional configurations are available to enhance the development tool - real device test run configuration. The following additional parameters are available for the gradle.build file.

See Also

Publication date: