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. androidTestImplementation 'com.blackberry.blackberrydynamics:atsl:6.0.0.26' implementation('com.android.support.test.espresso:espresso-contrib:2.2.2') { exclude module: 'support-annotations' } androidTestImplementation 'com.android.support:support-annotations:24.2.1' androidTestImplementation 'com.android.support.test:rules:0.4' androidTestImplementation 'com.android.support.test:runner:0.4' androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2' // Include tests in androidTest target androidTest { manifest.srcFile 'tests/AndroidManifest.xml' java.srcDirs = ['tests'] assets.srcDirs = ['tests/assets'] } // Following configuration is required to set the download location of // dependent projects. allprojects { repositories { mavenCentral() ..... maven { url '../../../m2repository' } } }
  2. Define AndroidJUnitRunner as the runner for test instrumentation. Add the following to the build.gradle file:
    android { ..... defaultConfig { ..... 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.