Skip Navigation

Add automated testing to your 
BlackBerry Dynamics
 
Android
 app

  1. Add the 
    Android
     Testing Support Library and the 
    BlackBerry Dynamics
     ATSL to your project. Your project must have a compile SDK level of 23 or higher. You can add the following to the build.gradle file to add both libraries:
    // Dependencies on the modules of the Android Testing Support Library. androidTestCompile 'com.android.support:support-annotations:23.0.1' androidTestCompile 'com.android.support.test:rules:0.4' androidTestCompile 'com.android.support.test:runner:0.4' androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.0.0' // Include the Automated Test Support Library in the androidTest target. androidTest { java.srcDirs = ['tests'] // Include the Automated Test Support Library package. // The automated_test_support_library_path value is defined in the // gradle.properties file. java.srcDirs += [automated_test_support_library_path + '/src'] java.srcDirs += [automated_test_support_library_path + '/src-handheld'] assets.srcDirs = [automated_test_support_library_path + '/assets'] } // Following configuration is required to set the download location of // dependent projects. allprojects { repositories { mavenCentral() } }
  2. Add a line similar to the following to the build.gradle file to define a runner for test instrumentation: 
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
  3. Add or write code for your app tests. Use the helper functions in the ATSL in your test code.
You can use the code for the app tests in any of the sample apps as a starting point. For example, in the SecureSQL sample app, the first app test, 
test1
, executes 
BlackBerry Dynamics
 activation and unlock as an automated test. Put the code in one of the source directories specified in the 
androidTest
 target. In the above example, only the 
tests
 sub-directory is specified.