Introduction
As mobile applications advance and become more popular, better support for testing mobile applications evolve. The mobile device’s system is a remote system for a desktop computer, so, when testing, you need additional tools for working with it from your PC. The first thing you need is access to the device’s operating system: viewing processes, created windows on the device and other features in mobiles devices that are important for testing. TestComplete, can see deep inside of mobile applications with its Object Browser feature. When testing, you may need to interact with the mobile device, copy files to it and modify its registry. You can perform these tasks, and many others, using TestComplete. TestComplete has a full set of features for easy and effective testing of mobile applications.
This article provides a tutorial on how to start testing mobile applications with TestComplete.
The article contains the following sections:
- The Tested Mobile Application - Describes the application we are going to test.
- Prepare for Testing Mobile Applications - Describes how to install and configure the tested software and how to connect the mobile device to the desktop computer to test it.
- Creating Mobile Application Tests - Describes how to create and configure a TestComplete project for testing the application, how to write tests, etc.
- Automating Mobile Application Tests - Describes how to fully automate all testing actions with TestComplete, such as launching the tested application, executing tests and closing the application after the tests are finished.
- Running Mobile Application Tests - Describes how to organize tests within the project and how to get testing results.
You can download the TestComplete project described in this article using the links from the box on the right.
The Tested Mobile Application
In our example we will test the Orders application running under Windows Mobile 2003. The Orders application is shipped with TestComplete 7.
The Orders Application
Like other Orders applications, this one works with a table of purchase orders: you can view the list of existing orders, add new orders to the list, as well as modify or remove existing ones. However, the tested application in this sample should reside on a remote mobile device, rather than on the local computer. The purchased orders are saved to the MyTable.tbl database file, so we should copy the file with the Orders application to the device.
Prepare for Testing Mobile Applications
Before we start writing tests for our mobile application, we need to install a synchronization tool and TestComplete, in order to work with the device on the desktop computer. Then we need to install the tested application to the device. After that we will be able to test applications running on the connected mobile device.
1. Installing Software
First, we should install a synchronization tool for working with the connected device. If you are going to test mobile applications using Windows XP on a desktop, you need Microsoft ActiveSync. The latest version is available on Microsoft’s web site: www.microsoft.com. If you are going to work with the device from Windows Vista, you should install the latest version of Windows Mobile Media Center (WMDC). You can download it from the same web site: www.microsoft.com.
After a computer is synchronized with the device, you can install TestComplete and then deploy the application to the device for further testing.
So, to be able to test mobile applications, you should install the following software:
- Install a synchronization tool to the PC (if not already installed). Use Microsoft ActiveSync for Windows XP or WMDC for Windows Vista.
- Install TestComplete. When installing, make sure that the Extensions | PDA support feature is checked:
Installing TestComplete
After you have installed the software, you should connect the device to the PC and then perform the following actions:
- Synchronize the PDA with the PC. Create a new partnership, if needed.
- After the PDA is synchronized, launch TestComplete. TestComplete will discover the connected PDA and offer to install the PDA Support Component on the device. Click Yes.
Installing PDA Support Request
- Wait until TestComplete finishes installing the PDA Support. If the components are installed successfully, the PDA node will appear in the Object Browser panel. Now you are able to work with the device from TestComplete:
The PDA Node in the Object Browser Panel
This node represents the tree of processes running in the PDA’s operating system. Here you can find more information about all objects that are currently existing in the mobile system, such as running processes and created windows; you can also easily navigate through these objects, view their properties and more.
Further in the article when describing the testing process we will imply that the mobile device is already connected and synchronized with the PC. This is very a important condition for successful testing.
2. Building the Mobile Application
As stated above, we will test the Orders application from the TestComplete samples collection. You can find it in the following folder:
<TestComplete Samples>\PDA\OrdersDemo\MSVC\Pocket PC 2003 (ARMV4)\Debug\Orders.exe
The <TestComplete Samples> path depends on your operating system, for instance, it will be the <Documents and Settings>\All Users\Documents\TestComplete 7 Samples folder in Windows XP. On Windows Vista and Windows Server 2008, TestComplete samples are located in the <Users>\Public\Documents\TestComplete 7 Samples folder.
Before you proceed, make sure that you have built the Orders.exe application to be installed on the mobile device
3. Deploying the Mobile Application for Testing
We install the Orders.exe just by copying the executable to the device using the PDA File Manager panel in TestComplete. You can also deploy the application on the mobile device from the development environment, for instance, Visual Studio. In our case, to copy the Orders.exe to the /My Applications folder on the device, you can do the following:
- Open the PDA File Manager panel.
- Go to the Orders.exe located on the desktop PC (..\MSVC\Pocket PC 2003 (ARMV4)\Debug\Orders.exe) and copy the executable and the MyTable.tbl database file to the PDA, for instance, to the /My Documents/My Applications/Orders.exe. You can find the MyTable.tbl database in the <TestComplete Samples>\PDA\OrdersDemo\ folder.
Copying the Application to the PDA
Now we are able to run the Orders.exe application located in the /My Documents/My Applications/ folder on the mobile device.
Creating Mobile Application Tests
After the tested mobile application is installed on the mobile device, we can start creating tests for checking the application’s functionality. Let’s start with creating a TestComplete project.
1. Creating the TestComplete Project
You can automate any testing actions by using TestComplete’s projects. In our case, we will create a new project for testing the Orders application running on the mobile device. To create a new project:
- Launch TestComplete. Click the Create a New Project item on the Start Page. The Create New Project dialog appears:
Creating the TestComplete Project
- Type the project name and select the location, you can also choose any of the test scripting languages available. In our case, the name is FunctionalTesting and the location is <TestComplete 7 Samples>\OrdersTCProject.
- After you have specified the project name, click Create. Now the project is created and we can add Orders.exe as a tested application.
2. Adding the Tested Mobile Application to the Project
To be able to simulate different actions over the tested mobile application, for instance, to run or stop Orders after finishing tests, we should add the mobile application to the WinCE Tested Applications project item. This item contains the collection of tested mobile applications. To add the WinCE Tested Applications item to the project, you can do the following:
- Right-click the FunctionalTesting project in the Project Explorer panel.
- Select Add | New Item from the context menu.
- When the Create Project Item dialog appears, choose the WinCE Tested Applications item from the list and then click OK.
Adding WinCE Tested Applications Project Item
Now let’s add Orders.exe to the tested applications list. To do this:
- Right-click the WinCETestedApps project item in the Project Explorer panel.
- Select Add | New Item from the context menu. After the Select Executable dialog appears, find the Orders.exe application and click OK to confirm:
Adding Orders.exe to the Project
Now you can easily run the tested mobile application on the device by selecting Run from the context menu in TestComplete:
Running Tested Application
It’s time to record some automated tests over the mobile application and then run them on the mobile device.
3. Recording Keyword Tests Over Mobile Applications
One of the advantages of automated testing is that you can record the needed tests once and then repeat them any number of times for checking the application’s functionality. TestComplete can record user actions over mobile applications just like it does with desktop applications.
We can perform user actions directly on the device by using a stylus. However, we can also perform actions from TestComplete’s PDA Controller panel. In this case, you can just click over the needed point on the device’s screen picture displayed in the panel and these clicks will be transformed to user actions over the device. You can also simulate button presses by clicking the appropriate buttons in the PDA Controller panel.
PDA Controller
To open the PDA Controller panel, select the View | Select Panels from TestComplete’s main menu. In the ensuing dialog choose the PDA Controller from the list and then click OK.
Let’s record a simple keyword test that will: open the Orders database, modify a record (for instance, the record about Susan McLaren) and then save the changes to the database.
To record a test, open the PDA Controller panel and perform the following steps:
- Right-click the FunctionalTesting project in the Project Explorer panel and select Edit | Properties from the context menu.
- In the ensuing Project Properties Edit Page choose PDA | General in the list on the left of the page and enable the Synchronize recorded events project option.
- Expand the WinCETestedApps node in the Project Explorer, right-click the Orders item and choose Run from the Project Explorer’s context menu. This will start the Orders application on the connected device.
The Orders Application
- Select Test | Record | Record Keyword Test from TestComplete’s main menu.
- Add the "Opening the database" comment to a test. To do this:
- Click Add Code to Test on the Recording toolbar. This will invoke the Add Code to Test dialog.
- Enter "Opening the database" into the text box of the dialog.
- Click Add to confirm comment addition.
- On the mobile device, do the following:
- Click the Open database button on the application’s toolbar.
- In the ensuing Open dialog, click on the MyTable.tbl item. This will open the given database and read data from it.
The Open Dialog
- Click the Add Comment to Test button from the Recording toolbar and type a "Modifying a record" comment into the test.
- Return to the device:
- Select the Susan McLaren record in the customer list.
- Click the Order Properties button on the main toolbar.
- In the ensuing dialog, change the product type in the "Product" field and increase the value of the "Quantity" field.
Modifying a Record
- Press OK to finish editing and close the dialog.
- Go to the Recording toolbar and add the "Saving changes made to the database" comment to the test.
- Click the Save database button on the Orders application’s toolbar.
- Click OK in the Save As dialog.
- Click Yes in the ensuing dialog to confirm replacing the existing file:
Replacing Confirmation
- Click Stop on TestComplete’s recording toolbar.
- After the recorded test appears, save changes made to the FunctionalTesting project.
The recorded keyword test will look as follows:
The ModifyingRecord Keyword Test
TestComplete records tests and gives them consecutive names, for instance, Test1, Test2 and so on. After the test is recorded, you can rename it and give a more appropriate name for the test.
In our case, we renamed the recorded Test1 test to the ModifyingRecord test. You can also add the description to the recorded test by clicking the Edit button (see the image above) in the KeywordTest editor.
Now we know how TestComplete records keyword tests. However, you may still be unclear as to what the recorded operations mean. The following section provides more detailed information about them.
5. Analyzing the Recorded Mobile Application Test
Let’s take a look at one of our test’s operations. For instance, a click over the wndToolbarWindow32 object’s first item has been recorded as an On-Screen Action operation:
The ModifyingRecord Test
The On-Screen Action operation performs user actions over objects. You may ask, what is the wndToolbarWindow32 object?
In TestComplete, you can assign custom names to processes, windows, controls and other objects, or, in other words, you can map an object to another name. By default TestComplete automatically maps objects during test recording. The two main benefits for mapping include:
- Makes your automated tests shorter and more readable (a custom name, say,
EditorWindow is shorter and more user-friendly than Sys.Process("Editor").Window("Editor", "*", -1)). - Makes automated tests and the object names independent of object properties, which may change from one application build to another.
So, "wndToolbarWindow32" is the mapped name for an object. Which object? You can find it in the NameMapping project item:
- Switch to the NameMapping project item and expand the PDA node in the Mapped Objects panel. Because the wndToolbarWindow32 object is a child of the wndmenu_worker object, you have to expand it to find the wndToolbarWindow32 object.
- Select Show in Object Browser from the context menu of the object:
The Mapped Object’s Context Menu
The corresponding toolbar is then shown in the Object Browser. In our case we see that the wndToolbarWindow32 object corresponds to the ToolbarWindow32 control which is used in the Orders.exe application. To the right of the Object Browser we can find a lot of methods and properties that are available for testing the toolbar. The FullName property contains the unique name of the toolbar. We can refer to this object by the full name too. TestComplete recorded a click over a toolbar’s item as a ClickItem action; you can also find this method in the Object Browser.
Viewing the Object in the Object Browser
Also you can select the Highlight on Screen from the context menu in the Object Browser and the tested control will be marked with the red frame on the PDA’s screen:
Highlighting the Toolbar
You can see how to determine the application objects by their mapped names after recording automated tests. But how do you find the object’s name when we are writing automated tests manually?
Easy! Suppose you need to simulate a click over the toolbar’s item, but you don't know how to refer to this object from a test. To determine the object’s name:
- Click the Object Properties button from the TestComplete’s toolbar.
- In the ensuing window, click the Point to Object button to select an object.
- Maximize TestComplete's window so you can see the mobile device’s screen.
- Point to the desired object with the mouse cursor so that the object is marked with a red frame. In our case, point to the desired toolbar.
- Press SHIFT+CTRL+A to obtain the object’s name:
Determining the Object’s Name
You can determine all objects and their names in the same way. Now we will automate running tests and then check results of testing the mobile application.
Automating Mobile Application Tests
After we have created all required functional tests for our application, we can automate the mobile application test execution with TestComplete. Furthermore, we can automate the whole QA testing process. To do this, we should configure our TestComplete project so that the tested application will launch and stop automatically according to the test’s progress.
Since each particular test or any automated action over a mobile application may be added as a project test item to the TestComplete project, we can specify a sequence of test items for our project and then run them just by running the whole project.
Now we will automate the open and closing of the mobile application and then specify the test items for our project.
1. Launching the Mobile Application
We will automated the launching of the mobile application (Orders) as a particular keyword test. We should also make sure that the tested application is running before we begin each test. To automate launching the tested mobile application:
- Create a new keyword test and name it, for instance, "RunningApp".
- Add the Run WinCE TestedApp operation to the test and specify "Orders" as its parameter.
- Add the If Object operation to the test. Select the "Aliases.Orders" object and choose the "Not Exists" condition as operation parameters.
- Add the Stop Execution operation as a child for the previous operation.
- Save changes to the project.
The resulted keyword test will look as follows:
The RunningApp Automated Test
2. Stopping the Mobile Application
Let’s create another keyword test to automate closing of the tested mobile application (Orders). To automate closing the tested mobile application:
- Create a new keyword test, for instance, name it "StoppingApp".
- Add the Call Object Method operation to the test. Specify the WinCETestedApps.Orders as the object and click Next:
Specifying the Object for Call Object Method
- Then choose the Close method as the parameter and then click Finish:
Selecting a Method for Call Object Method
- Save changes to the project.
-
The resulted keyword test will look like the following:
The StoppingApp Automated Test
Now we can automatically launch and close the Orders application with TestComplete. This helps us automate the whole QA testing process.
3. Specifying Project Test Items
The last step of preparing the project is specifying a desired sequence of tests, or project test items. The Test Item list is a test execution order, in other words, a battery of tests. After we have made the list, we can just run the project and all automated tests will be executed automatically in the specified order.
To specify project test items:
- Right-click the FunctionalTesting project in the Project Explorer.
- Select Edit |Test Items from the context menu. The Test Items page displays:
Project Test Items Page
- Click the New Test Item button from the toolbar. A new row will appear in the test item list.
- Click the ellipses button for the new row in the Element to be run column.
- Specify the first automated test for our project, the RunningApp keyword test.
- By adding other test items in the same manner, make the sequence of items as it is shown in the following image:
Automated Test Execution Order
- Save the changes made to the FunctionalTesting project.
Now the project is ready for automated testing of the mobile application. Of course you can specify any number of test items in any order, associate them into groups and specify their run parameters, if needed.
Running Automated Tests with Mobile Applications
To begin automating the testing of mobile applications, we can just select Run Tests1 [Project] from the FunctionalTesting project’s context menu. After the test finishes, we will be able to see the automated test results in the Test Log panel. For instance, the results may look as follows:
Mobile Application Test Results
Test results are saved in TestComplete’s project. You can view, compare results of testing different application builds, make appropriate decisions, re-test and perform other testing actions. You can also export the test results in an XML format for use in other applications like homegrown bug tracking systems.
Conclusion
TestComplete makes testing of mobile applications easier, faster and less costly. It also has a lot of useful panels that simplifies the process of working with the connected mobile device.
Through this tutorial, you have learned how to test mobile applications, particularly, applications developed for WinCE-based operating systems, with TestComplete. As you can see, recording different functional tests and then automating them over mobile applications is a snap with TestComplete’s keyword tests. TestComplete also has automated test scripts which were not shown in this tutorial. However, you can also use these same steps for the scripting approach.
If you haven’t tried TestComplete 7 or if you are interested in testing mobile applications with TestComplete, download and try it today.