Automated testing with the BlackBerry
        Dynamics sample apps
    BlackBerry
        Dynamics
 sample appsThe sample apps included in the 
BlackBerry Dynamics SDK
 have been integrated with the BlackBerry
        Dynamics
 Automated Test Support Library (ATSL). Each sample app includes test code that executes automated tests of processing and behavior.You can use the integration of the ATSL in any sample app as a guide for integrating the library with your own 
    
BlackBerry
        Dynamics
 apps. Note the following details about the ATSL integration:
        
  | Item | Description | 
|---|---|
| Build target for testing | Each app has an  androidTestbuild target that the AndroidPlugin for Gradlecan use. For more information about the AndroidPlugin for Gradle, see Android Studio: Configure your build. | 
| Code for JUnit tests | The test code is located in the sub-directory  <sample_app>/tests/ <sample_app_package>/test/. The code is based on JUnit4. You can run tests with  AndroidJUnitRunner. | 
| Use of ATSL for interaction with  BlackBerry
        Dynamicsscreens | The test code uses helper functions in the ATSL. For example, the following code executes the entire activation process for the app: 
 The user's email, access key, and password are read from a file in JSON format (see Preparing for automated testing). You can run ATSL helper functions in the JUnit assertion programming interface. For example: 
 This assertion will fail if activation fails. Each  BlackBerry
        Dynamicsscreen is represented by an object that provides convenient methods to interact with the UI elements that it consists of. You can use the following snippet to enter user credentials and start the activation process using credentials that are not stored in the JSON file:  
 | 
| Use of ATSL for general interactions | The test code also uses helper functions in the ATSL for general interactions (for example, checking that an item exists in the user interface and then interacting with that item). See the following example: 
 The ATSL functions handle this by using UIAutomator. | 
| Broadcast receiver for authorization events | The test code registers a broadcast receiver that receives authorization events from the  BlackBerry Dynamics SDK: 
 Broadcast receiver registration supports multiple receiver classes and doesn’t block  GDStateListeneror GDAppEventListenerimplementations, if any. The broadcast receiver code is in the GDSDKStateReceiverclass. |