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.
The installation of any Gradle compatible plugin is straightforward. There are two different gradle.build files - one specific for Project and one for Module. To make it easier to adopt these configurations for a variety of different projects, modify the Module specific gradle.build 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 (compile and upload 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 8 pre-selected devices.
authorization "OAUTH2" //optional "APIKEY"|"OAUTH2"(default)
apiKey "d409cad93079b6c6cd55b79e927b17j4" //required if authorization "APIKEY"
Instead of the preferred APIKEY authentication method presented above, it is also possible to use the username and password.
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 please check the latest version from here. For the dependency configuration, please use the following line as part of the buildscript > dependencies:
That’s it! Gradle build is now executable in BitBar against the defined device group.
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 (e.g.
/Users/vvhelppi/AndroidStudioProjects/MyApplication2) and executing the following command:
or using the Android Studio’s Gradle Projects view and double-clicking
testdroidUpload under Tasks (app > verification):
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:
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.
The example above shows a test run from an empty Android Studio app project on 8 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 use those as test cases.
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.
username "firstname.lastname@example.org" // Username
password "password" // Password
deviceGroup "MyTestDevices" // Device group for execution
cloudUrl = 'https://cloud.bitbar.com' // Optional - Used for PrivateCloud configs
projectName "Project 1" // Optional - Default: create a new project
mode "FULL_RUN" // FULL_RUN / APP_CRAWLER / UI_AUTOMATOR
testRunName "Custom test run name" // Optional - default: build variant name
deviceLanguageCode "en-US" // Optional - locale <ISO 63>_<ISO 3166> default: en-US
hookUrl "http://localhost:9080" // Optional - call back URL after test run has finished
scheduler "PARALLEL" // Optional - PARALLEL or SERIAL default: PARALLEL
testScreenshotDir = "/sdcard/abc" // Optional - custom screenshot folder
// AppCrawler configuration - set application credentials
applicationPassword = "appPassword2"
applicationUserName = "appUsername2"
// Optional - Custom settings for test execution
instrumentationRunner = "com.android.testRunner"
withAnnotation = "com.my.annotation"
withOutAnnotation = "com.my.not.annotation"
limitationType = "CLASS"
limitationValue = "foo.bar"
instrumentationAPKPath = "/tmp/mytestapp.apk" // Optional - custom instrumentation apk path
uiAutomatorTestClasses = "foo.class"
uiAutomatorJarPath = "tmp/uitests.jar"