Applies to TestComplete 14.20, last modified on September 11, 2019

This topic explains how to prepare an Android application for testing with TestComplete.

Why Preparation Is Needed

The preparation (or instrumentation) of tested Android applications is not mandatory. You can test your Android application as it is, without preparing it for TestComplete. However, in this case, you will be able to create only image-based tests. Although these tests may be enough in some cases, we recommend that you instrument your applications for TestComplete and test instrumented applications, when possible.

If an application was prepared for TestComplete, the latter recognizes individual controls in that application and provides control-specific methods and properties that help you simulate user actions on controls easily. Also, your tests get access to “native” methods, fields and properties of Android controls. All these help you create more powerful tests that can be easily ported to various Android devices.

We call instrumented Android applications white-box or Android Open Applications (as they are “open” to TestComplete).

What Instrumentation Means

To instrument an Android application, you need to compile it with the PatchServices.jar library and insert a method call into the application for initializing the library.

The library is part of the TestComplete package. You can find it in the <TestComplete>\Bin\Extensions\Android folder.

Notes
  • During instrumentation, TestComplete does not change the application’s source code. Only binary code is affected.

  • Do not submit instrumented applications to the Google Play. Instrumented applications use private APIs and will be rejected. Create a separate build configuration for test builds.

  • TestComplete does not change the binary code of your functions, resources and text constants in your code. It just compiles the code and adds an initialization call. That is, the changes TestComplete makes do not affect the application functionality.

    If your application uses the WindowManager.LayoutParams.FLAG_SECURE flag, TestComplete will reset this flag for every activity window during instrumentation. For more information about the flag, see the Android documentation for developers.

  • The PatchServices library exchange information with TestComplete through the TestComplete Android Agent installed on your device. The library does not create new network connections.

  • Instrumented applications consume a bit more memory on the device due to the library code, which TestComplete adds to them.

  • It is impossible to revert the instrumentation actions. If you need an uninstrumented binary of your application, restore it from the backup copy.

Preparation Steps

1. Instrumenting Your Application

To instrument an Android application, you need to compile it with the PatchServices.jar library and insert a method call into the application for initializing the library. You can command TestComplete to perform these actions automatically, or you can do all the preparation actions manually in the Eclipse IDE or Android Studio. Follow these links for detailed information:

Note: Xamarin applications can be instrumented in TestComplete only.

2. Installing Android Agent on the Device

Important: in order for TestComplete to be able to interact with Android Open Applications, you need to install TestComplete Android Agent on your device. For complete information about the Agent and installation steps, see the Agent description.

Other Preparatory Actions

In order for TestComplete to be able to work with Android applications, in addition to instrumenting the application, you also need to prepare the TestComplete computer, as well as your Android device, emulator or virtual machine. For complete information on these actions, see the other topics of the Preparing for Testing Android Applications section.

See Also

Preparing for Testing Android Applications
About Testing Android Applications

Highlight search results