Would you like to contribute to the Titanium docs? To get started, sign up for an account on the Appcelerator Wiki and sign our CLA.

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Removed dead links and images

...

Enabling Appcelerator Services 
Anchor
enable_appc_services
enable_appc_services

To use the Test service to test an application, you must enable Appcelerator Services in your project. This adds the TouchTest module to your project, and the code required to load and initialize it. (For specific code and configuration changes, see Platform Services). Do not modify these changes or you may disable the Test service in your application.

For native Android and iOS applications, use the appcelerator-test utility utility to enable the Appcelerator Test service.  For instructions, see Appcelerator Test CLI Reference.

For Titanium applications, use Appcelerator Studio to enable Appcelerator Services when creating a new project by selecting an option in the new project dialog, or in an existing project. If you have an existing Titanium Studio application, you'll first need to import that application in to Appcelerator Studio (see Migrating an Existing Project to the Appcelerator Platform).

To enable Appcelerator Services in a new project:

  1. In Appcelerator Studio, create a new Mobile App Project (File > New > Mobile App Project).
  2. Check the Appcelerator Services check box in the Mobile App Project wizard dialog.

...

To run tests on a device you need to install the TouchTest Agent a light-weight software agent that controls the device during test recording and playback. Once installed you also need to register your device with the Test service, and have the device approved by an administrator (see Approving devices and simulators).

Device and OS requirements

...

  1. Point your device's or emulator's web browser to the TouchTest Agent URL ( http://appctest-2.appcelerator.com/concerto/touchtest ).
  2. In the login form enter your enter Appcelerator Platform credentials. You must append your organization ID to your login name (see Logging in to TouchTest Agent).
  3. Click Tap Here to Download TouchTest Agent.
  4. Open the APK file that was downloaded to install the TouchTest Agent. 
  5. Open the TouchTest Agent application.
  6. In the  TouchTest Agent URL  field enter the TouchTest Agent URL and  click  Go .
  7. Enter your Appcelerator Platform credentials. You must append your organization ID to your login name (see Logging in to TouchTest Agent).
  8. On successful login, enter a name for your device and click Submit for Approval.
  9. Once the device has been approved, the TouchTest Agent displays its current connection status to the Test web service, as well as the current TouchTest URL, user name, and TouchTest Agent build number.

You can now record a clip on the device.

Installing TouchTest Agent on an iOS device or simulator

...

  1. Point the device's Safari browser at the TouchTest Agent URL ( http://appctest-2.appcelerator.com/concerto/touchtest ).
  2. Enter your Appcelerator Platform credentials and login (see TouchTest Agent user name).
  3. Click Register Device. The Install Profile dialog opens asking you to install the TouchTest Device Registration profile.
  4. Click Install in the Install Profile dialog, then click Install Now in the confirmation dialog. (You may also be prompted for a passcode by the device, if that security feature is enabled.)
  5. Enter a name for your device and click Submit for Approval.

  6. Once the device has been approved, the TouchTest Agent displays the current connection status to the Test web service, TouchTest URL, user name, and TouchTest Agent build number.

...

  1. Point the simulator's web browser at the TouchTest Agent URL ( http://appctest-2.appcelerator.com/concerto/touchtest ).
  2. Click Tap here if this is a simulator.
  3. Enter your Appcelerator Platform credentials and login.
  4. Click Register  Simulator.
  5. For simulators running iOS 6 or earlier, provide your computer's hardware UUID. See Finding your system's Hardware UUID for detailed steps.
  6. Provide a name for your device and click Submit for Approval. (The name must be unique among other registered devices in your organization.)
  7. Once the device has been approved, the TouchTest Agent displays the current connection status to the Test web service, TouchTest URL, user name, and TouchTest Agent build number.

...

To record or playback a test, the TouchTest Agent must be running on the test device. These steps assume you've already installed the TouchTest Agent and had your device registered and approved (see Installing the TouchTest Agent for instructions).

To start the TouchTest Agent on your device, simulator, or emulator:

  1. Close the installed application to test, if it's open.
  2. Open the TouchTest Agent:
    • On Android, open the TouchTest Agent application that you installed.
    • On iOS, open Safari and navigate to the TouchTest Agent URL.
  3. Provide your Appcelerator Platform login credentials, if prompted (see TouchTest Agent user name).

When launched, the TouchTest Agent displays its current connection status. Make sure the Status field says "Connected", as shown below. You're now ready to record a clip.

...

When logging in to the TouchTest Agent, the user name you provide must be followed by a forward slash (/) and your organization's ID (see Locating your organization's ID). For example, if your primary login name is "user@appcelerator.com", and your organization ID is "12345", then your login name would be "user@apppcelerator.com/12345".

...

  1. Open the Appcelerator Test dashboard in your browser.
  2. Select Device Clouds from the left pane.
  3. In the right pane, locate the newly registered device whose status is Pending Approval, and click Approve
    Image Removed
    Once approved, the device's status changes to  Connected, if the TouchTest Agent is open on the device.

...

Once you've created a TouchTest-enabled project in Appcelerator Studio (by enabling Appcelerator Services), the next step is to build and install the application on the test device, simulator, or emulator. You can use either the Run or Test commands to build and install the application on the target device.

...

  1. On the test device, open the TouchTest Agent and ensure its connected to the Test service (see Launching the TouchTest Agent).
  2. Open Appcelerator Dashboard and click the Test tab.
  3. Select the application to test from the Application menu in the upper-left corner.

    Tip

    To quickly access the Test tab for your application from Appcelerator Studio, click the Details link next to the Test entry in your project's tiapp.xml file.

  4. With your application selected, on the Central tab select Clips in the left navigation, then click the New button. The Clip Editor opens a new untitled clip.
     
  5. In the Clip Editor, click the Record menu and select Record Mobile App
  6. In the Choose a Device Agent and Mobile App dialog select the test device from the upper pane, and the application to test, and click Record.


  7. The test application launches on the device. Perform actions on the device according to your test scenario – tap buttons, input text, perform gestures, and so forth. Your actions are recorded as App Actions in the Clip Editor.
  8. When finished recording, click the Record button in the Test tab in Dashboard again to stop recording.
  9. Click Save or Save As Image Removed in in the toolbar, give the clip a name or accept the default, and click Save.

To playback a test clip that you've recorded, it needs to be added to a test composition. See Creating a composition.

 

Creating a test composition

A test composition is the actual test that's executed on the device. A composition consists of one or more clips arranged on tracks. Youedit compositions in the Composition Editor. You can organize tracks in the desired sequence, select target devices on a per-track or per-clip basis, and other settings. The Composition Editor is also the player, debugger, and dashboard where test results are displayed. Each of these functions is presented in separate tabs named Edit, Debug, Play, and Results, as shown below.

To create a composition from the Clip Editor:

  1. With your test clip open in the Clip Editor, click  Use in Composition Editor menu in the upper-right corner of the Clip Editor toolbar.  

     
    An explanation of menu items:

    • Open in Test Composition – Adds the clip to a new draft composition where additional composition parameters can be set before proceeding to play.
    • Play in Test Composition – Adds this clip to a new draft composition that immediately begins playback.
    • Debug in Test Composition – Adds this clip to a new draft composition where it can be debugged. 
  2. The Composition Editor opens with a draft test composition that has the recorded test clip in Track 1.

    Align
    alignright
    classsidebar

    Tip: Double-click the track name to edit it.

    By default, the device that was used to record the clip is automatically selected as the playback device (iPhone 7 simulator, in the above screenshot). You can select connected device by clicking the Device pop-up menu.

     

  3. Click Save or Save As Image Removed Composition Editor toolbar and give the test composition a name or accept the default name. 

You can also create an empty test composition and add existing test clips to it.

To create an empty test composition
:
  1. On the Central tab select Composition from the left navigation and then click the New button. The Composition Editor opens a new untitled composition.
  2. Click the Composition Builder tab to open it, if not already open.
  3. Drag a test clip from the Composition Builder panel and drop it on the existing Track 1. Repeat to add more test clips.
  4. Save the composition.

Playing a composition

During playback the actions in the test clip are repeated precisely as when they were recorded.

To play a test composition open in the Composition Editor:

  1. Make sure the TouchTest Agent is open on your test device and its status is “Connected”.

  2. In the Composition Editor, click Play to run the test composition. The app actions performed when the clip was created are played back on the device.
    Image Removed Once playback has started on the device, the Result Details dashboard opens.

 

Result Details dashboard

The Result Details dashboard displays results from playback of a test composition. Results are posted continuously as playback progresses. If the composition fails for any reason, the dashboard clearly indicates the error and provides details as to what caused it. Results are displayed in a cover-flow view and in an expandable tree control on the left. As play continues, the focus is set to the last executed element. Clicking an element during play will pin the focus on that element.

...

Most app actions (with a few exceptions) have a Locator input property that identifies the UI element to apply the action too. A locator can take several forms, such as by the element's classname (UIButton, for example), the text it contains, an XPath expression,  or by a unique ID the developer assigns to a UI view (see  Using touchTestIDs ). For a complete list of locators you can use, see the Locator reference

  For example, suppose an application contains an input text field with the placeholder text "What do you need to do?", as in the Alloy Todos sample application.   

...

When creating the test, you can specify the TextField element with the locator id=todoInput

 

You can use the Locator tool to determine an element's touchTestIDs, if any.

...

Locator nameDescription
kindof

Locates elements that are a subclass of the specified class. For example, kindof=UIButton will find UIButtons, as well as UIRoundedRectButtons.

classname

Locates elements that are of the specified class. For example, classname=UIButton will find only UIButtons but not UIRoundedRectButtons.

xpath

Locates any element that matches the specified Xpath. Use the outputXmlHierarchy accessor to see the XML to which the XPath is applied. Usage:

  • //UITableView//UILabel[@text="Carbon"]  
  • //UITableViewCell[UITableViewCellContentView/UILabel[@text="Pickers"]]/UIButton
  • //UIDatePicker[@touchTestId="DatePicker"]//UIPickerTableView[0]
partialText

Locates elements that contain the specified text. Usage: partialText=for all good men

textStartsWith

Locates elements that have text that starts with the specified text. Usage: textStartsWith=Now is the time

textEndWith

Locates elements that have text that ends with the specified text.

Usage: textEndsWith=aid of their country.

text

Locates elements that have text that matches the specified text exactly.

Usage: text=Login

indexLocates elements that have the specified index in the view hierarchy. It's usually used in conjunction with other locator strategies, and is assumed if no strategy is given (ie. UIButton[2] is the same as UIButton[index=2].
placeholder

Locates elements that have a placeholder property that matches the specified text.

Usage: placeholder=User name

touchTestId

Locates elements that have a touchTestId property that matches the specified text. See Using touchTestIDs for more information.

Usage: id=addItem_btn

accessibilityLabel

Locates elements that have an accessibility label that matches the specified text. Accessibility labels can only be used when the device has the VoiceOver accessibility feature turned on.

Usage: accessibilityLabel=User name

tag

Locates elements that have a tag property that matches the specified integer. Tags are an integer set by the developer to identify views in the application.

Usage: tag=20

...

During a recording your actions are recorded as App Actions in the Clip Editor. After recording, you can edit properties of the recorded actions to modify their behavior, timing, and output.

You can view App Actions in a list or icon format. 

Double-clicking an action opens a bottom tab where you can edit the action's properties.

Each action has the following properties and commands you can use to configure its behavior:

You can also view and edit an action's properties in the list view.

...