Automated testing with the BlackBerry
Dynamics sample apps
BlackBerry Dynamicssample apps
The sample apps included in the
BlackBerry Dynamics SDKhave been integrated with the
BlackBerry DynamicsAutomated 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 Dynamicsapps. Note the following details about the ATSL integration:
Build target for testing
Each app has an
androidTestbuild target that the
Gradlecan use. For more information about the
Gradle, see Android Studio: Configure your build.
Code for JUnit tests
The test code is located in the sub-directory
The code is based on JUnit4. You can run tests with
Use of ATSL for interaction with
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.
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
GDAppEventListenerimplementations, if any. The broadcast receiver code is in the