Creating application stubs in tests

You can use the test editor to add application stubs manually in your test. You can create stubs for Android, iOS or hybrid applications.

About this task

An application stub is a program or a piece of code used as a placeholder to simulate the behavior of software components such as a procedure on a remote machine. Use of this application stub will depend on the application being tested. The stub application replaces and simulates the behavior of the real object. The source code is temporarily replaced with a simple statement that returns a specific value to the application under test. You can manually create a stub without using a template, but consider using the stub created automatically in the recording application as a template for your application stub.

Example: To illustrate the use of stubs in a mobile application: When you tap a phone number from a mobile device, you call this number, or if you tap an email address, you launch your mailer to send an email to this address. During the test recording, HCL OneTest™ UI is able to detect this action (call or email) and to replace it by a stub instruction in the script so that there is no need to perform the action during the playback.


To manually create application stubs

  1. In HCL OneTest UI, open the test script and in the Test Contents area, click in the launch node where you want a stub to be added.
  2. Click the insert button and select Application stubs. Alternatively, right-click the selection or click Options and insert in the test editor to select the menu item.
  3. In the Test element details area, enter the name of the stub application that will simulate a service or a process. The name should contain key and scheme values.
  4. In the Input values section, click Add parameters and enter a name for the operation element that describes the call that the stub expects to receive (scheme, data, and flag, for example), select the format (string, array, or other) of the call in the list items and a value retrieved from the recording app.
  5. You can optionally enter values for the Result code and return values. The return value is the content that is returned by the stub service, simulating the response of the original service. This is the simulated value or canned value. There is one response element associated with each case element. Click Add parameters to enter a name for the response element, and then select a format and a value. If you want to delete all parameters, click the Remove all button.
  6. The stub action is added to the test script with the name of the application stub before the item initially selected.
  7. Save the test.