banner 728x90

Test your Dynamics apps with BBD automated test support for iOS

banner 728x90

1x1.trans - Test your Dynamics apps with BBD automated test support for iOS

If you have ever developed an app that requires user verification, you will know the pain of entering test@test.com and abc123 in your login text fields every time you want to see how that new color looks red on an UI button. Of course there are solutions for this, such as automatic login methods and pre-filled text fields, but these solutions can jeopardize the security of your application. Do not be afraid; with BlackBerry Automated Testing Support Library for the BlackBerry Dynamics SDK you will never have to enter a abc123 password again (unless this is your computer password, which I would not recommend)!

Getting started with the support library Automated tests

Although the Automation Test Support Library for BlackBerry Dynamics SDK includes a plethora of powerful test features, a good starting point for integrating the library with your app tests is automated logon. This project uses BlackBerry's newly released BlackBerry Dynamics SDK Beta; sign up here to access the SDK Beta. Before you begin, be sure to follow these instructions to install the BlackBerry Dynamics SDK for iOS if you have not already. Note to follow only the linked instructions until Implement and test > App users of end users part 6; the remaining steps are automated by the next test. At the end of the linked tutorial, a blank BlackBerry Dynamics application is run and set up with your UEM server .

Once you run an empty BlackBerry Dynamics app on your device, it's time to add the required libraries to test! The AutomatedTestSupport library must be added to your project directory by default before you can use its functions. In Finder, navigate to ~ / Library / ApplicationSupport / BlackBerry / Good.platform / iOS / AutomatedTestSupport and drag "Core" to your Xcode projects under the UITests folder. Make sure "Copy items if necessary" is selected, along with "Create groups" and all targets are selected.

1x1.trans - Test your Dynamics apps with BBD automated test support for iOS

Now that the libraries have been added, it's time to go into some encoding. We start by creating a file containing your login details that the UITEST will use to automatically fill in the fields E-mail address, Access code and Password! Start by creating a new empty file under UITests with the name "credentials.json". In the new json file, paste the following code:

  

Each GD_TEST_PROVISION property represents a string that is automatically filled in by the BlackBerry automated test library. Start by entering your user e-mail address, followed by generating a BlackBerry Dynamics Access Key in the UEM console. Paste the newly generated access key into the credentials.json file and be sure to remove all dashes and spaces (the key must be a 15-character string). Finally, enter a password that you want to use to log in to your Dynamics application. Now it's time to switch to the meat and the potatoes of this tutorial: encode the test!

Note: If you are using the latest beta version of BlackBerry Dynamics SDK 4.0.0.5648, you must add a property .sc3 to your URL Schemes in the Info.plist of your app. Because the latest beta version also allows the use of Apple's new face ID feature to log in to Dynamics, you must also add a NSFaceIDUsageDescription key to your Info.plist, accompanied by a short description of why your app requires this access.

Automated test library with Objective-C

Start by adding the header file BBDAutomatedTestSupport by pasting the following line in UITests.m:

#import "BBDAutomatedTestSupport.h"

Then delete the XCUIA application call under the setUp method; we will move this to a modified test method. The test method that we are going to use, testProvision, performs two tests: verify that the user has successfully activated his BlackBerry Dynamics app and easily check that the main user interface is displayed on the screen. To reach the last of the two, go to ViewController.m and paste the following code to indicate that ViewController is your main user interface:

self.view.accessibilityIdentifier = @ "MainVC";

Now is the time to automate your test. Open UITest.m and replace the method named testExample with the following code:

 - (void) testProvision 

- (void) fetchCredentials  

The fetchCredentials method looks at the credentials.json file that you created earlier and passes the information to the BBDAutomatedTestSupport library to automatically fill the text fields when logging in. You are now ready to test your app!

Automated test library with swift

If you are a modern Swift programmer, there is a small extra step you need to follow in order to access the BBDAutomatedTestSupport library: add a bridging header. To do this, press the + button in the bottom left corner of Xcode to add a new file; select "UI Test Class Case", set the language to Objective-C and select "Okay" when you are prompted to create a bridging header file. This is a small hack that I gained during my Xcode projects; as opposed to doing it manually, this method of creating a bridging header allows Xcode to configure the project settings to include the file. You can now delete the .m UI Test Class Case file that you just created. In the -Bridging-Header.h file, enter the following code:

#import "Core / BBDAutomatedTestSupport.h"

Then delete the XCUIA application call under the setUp method; we will move this to a modified test method. The test method that we are going to use, testProvision, performs two tests: verify that the user has successfully activated his BlackBerry Dynamics app and a simple test when the main user interface is displayed on the screen. Go to ViewController.m and paste the following code to indicate that ViewController is your main user interface:

self.view.accessibilityIdentifier = "MainVC"

Now is the time to automate your test. Open UITests.swift and replace the method named testExample with the following code:

 func testProvision () 

func fetchCredientials () 

The fetchCredentials method looks at the credentials.json file that you created earlier and passes the information to the BBDAutomatedTestSupport library to automatically fill the text fields when logging in. You are now ready to test your app!

Construction and test

You are now ready to test your application and take advantage of the powerful features offered in the BlackBerry Support Library for automated testing! If this is the first time you start your app on your device, you will need to build and run your app to configure it with the BlackBerry UEM Client application; If you do this in test mode, the test stops prematurely. After you have been configured with the UEM Client app, you build and test your application and see how the support library for automatic testing automatically fills in your login data!

Moving forward

Congratulations, you have successfully built and tested your first iOS app with the BlackBerry Automated Testing Support Library! After you finish celebrating this triumph, try implementing the unLockBBDApp method to unlock an app previously locked with the UEM console or the waitForRemoteLock method to unlock the BlackBerry UEM Remote Lock functionality. to test. The test that you have just built is standard in all Objective-C examples in the BlackBerry Dynamics SDK, so testing it is now a piece of cake; You can also refer to the sample tests for more information on how you can use the framework to speed up your test workflow. You can also view this great blog to get started using the test framework for your Android apps. This is only the beginning of what you can now test with the support library; With this primer you can now take your iOS test skills to a higher level and encode with confidence. Satisfied testing!

test your dynamics apps with bbd automated test support for ios - Test your Dynamics apps with BBD automated test support for iOS

About Connor Holowachuk

Connor Holowachuk is a student of Enterprise Solutions Development at BlackBerry.

banner 728x90
author
Author: 
    Script & Style Show: Episode 1: Marc Grabanski
    Script & Style Show: Episode 1: Marc Grabanski
    During this second episode of the Script
    AWS AppSync region expansion and new functions for API keys
    AWS AppSync region expansion and new functions for API keys
    AWS AppSync, a managed GraphQL service with
    What is the best time to involve your mobile app users?
    What is the best time to involve your mobile app users?
    When talking to customers about mobile analysis,
    How to make a Twitter bot with Node.js
    How to make a Twitter bot with Node.js
    Twitter bots have been in the news

    Leave a reply "Test your Dynamics apps with BBD automated test support for iOS"

    Must read×

    Top