MQA plays nicely with Cordova

My brother and I never got along when we were kids. I suppose that happens with most siblings. I would want to watch a movie, while he preferred to read comic books. We quite simply didn’t mesh that well together. Similarly, IBM Mobile Quality Assurance (MQA) and Apache Cordova are great products by themselves, but they could never interact with each other. Until now. In this tutorial, I will show you just how easy it is to make them work together (much easier than for a parent of siblings).

Cordova is one of the hot new ways to develop mobile apps by leveraging the web technologies that are in use today. What does this mean for developers? Well, it is no longer the estranged little brother to IBM MQA. Now, they play nicely together. In the rest of this post, I will explain how.

Register for IBM Bluemix

To implement MQA into a Cordova app, you must first register for Bluemix and create an instance of MQA. This tutorial isn’t about how to register for Bluemix, so I’ll point you to the instructions: www.ibm.com/support/knowledgecenter/SSJML5_6.0.0/com.ibm.mqa.uau.saas.doc/topics/t_setup_mqa_services_saas.html. Don’t worry, it is super easy!

After creating the instance of MQA, follow these steps to instrument MQA into your Cordova app:

Download and install the Cordova CLI from the Apache website

http://cordova.apache.org/docs/en/5.0.0//guide_cli_index.md.html#The%20Command-Line%20Interface.

Download and unzip the Cordova MQA SDK

www.ibm.com/support/docview.wss?uid=swg27044490.

Create your Cordova project

C:\Cordova>cordova create Hello com.example hello

Change the directory to your project folder

C:\Cordova>cd Hello

Add the platform (android/ios)

C:\Cordova\Hello>cordova platform add android

Add the 'device' plugin

C:\Cordova\Hello>cordova plugin add cordova-plugin-device

Add the MQA plugin

C:\Cordova\Hello>cordova plugin add "C:\Users\IBM_ADMIN\Desktop\MQA Plugin"
Or, the location of the MQA plugin.

Add the MQA.startNewSession code in index.js file

Include your appkey from the MQA instance in Bluemix. The index.js file is located in the project_root_folder/www/js folder.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
onDeviceReady: function() {
        app.receivedEvent('deviceready');
        MQA.startNewSession({
            mode: 'QA',
            reportOnShakeEnabled: true,
            android: {
                appKey: "your app key",
                notificationsEnabled: true
            },
            ios: {
                appKey: "your app key",
                screenShotsFromGallery: true
            }
            },
            {
                success: function (params) {
                    console.log("MQA initialized", params);
                },
                error: function (error) {
                    console.error(error);
                }
            }
        );
}

Build the app

C:\Users\IBM_ADMIN\Desktop\Cordova\Hello>cordova build

Run the app

C:\Users\IBM_ADMIN\Desktop\Cordova\Hello>cordova run

If it is configured correctly, you see screens that include a short tutorial on how to use MQA. If you want to try this procedure, try MQA now on IBM Bluemix.

My brother and I compromised and now watch comic book movies together. Similarly, MQA and Cordova integrate seamlessly with each other. Stay tuned for more posts from Rob Puryear and the IBM MQA team.

Last modified on May 01, 2016
Share this post: