Last updated: Oct 17, 2019 13:54
Setting up the Gradle plugin involves the following:
- Installing the Gradle plugin to prepare the build.gradle file
- Configuring parameters through a configuration file, the command line, or encoded in the build.gradle file
- Activating the plugin, understanding the output, and connecting to Smart Reporting execution reports
The Gradle plugin supports Gradle tasks for iOS environments. Use the task named "perfecto-xctest".
Each task supports the following actions:
- Reading of Perfecto configuration parameters that select the devices to install and run the instrumentation tests
- When working inside Android Studio, checking if there are tasks to build the application and testing .
apkfiles (and if any .
apkfiles are present, activating them)
- Installing the application, testing .
apkfiles on Perfecto Lab devices, and running the test methods
- Generating output to the Gradle console and the Perfecto single test report (STR) report
Executing XCUITest and XCTest tests involves the following application files:
- The application .ipa file. This includes the XCTest unit tests.
- The UI Runner .ipa file. This includes the XCUITest UI test methods.
To create the files and convert them to .ipa files:
In Apple Xcode, change the scheme destination to Generic iOS device.
Click Product > Build For > Testing. Once this is complete, open up the Organizer and select the latest version.
Right-click the generated .app file in the Project Navigator (in the Products folder) and select Show in Finder.
Finder displays the path to the Products folder and shows the following
The application package
- An app package for the UI tests named *UITests-Runner
- To convert the files to
.ipafiles, do one of the following:
- Supply the path to the application package path to this file as the testAppPath configuration parameter. The Gradle plugin will convert it to an .ipa file.
- Do the following to convert each of the files to .ipa files:
Create an empty "Payload" (case sensitive) folder and copy the .app bundle to this folder.
- Right-click the Payload folder and compress it to a zip file.
- Rename the .zip file to <testName>.ipa.
Create a new file named build.gradle.
Add the lines to the build gradle file that define the location of the plugin library and the dependency on the plugin. Gradle will look to verify that the plugin is installed before performing the task.
This is the recommended configuration method. However, if there are problems using the automatic download method described here, you can download the Perfecto Gradle plugin manually.
Do one of the following, depending on whether the plugin library is already downloaded or you want to locate and download the plugin library automatically:
To configure Gradle to automatically locate and download the plugin library, add the following lines to build.gradle file:
If the plugin library is already downloaded to a folder (for example the libs sub-folder), add the following lines to the build.gradle file:
Add the line that defines the plugin task:
- Add the plugin configuration settings by including the following Lab authentication parameters:
- The URL for the Perfecto Lab
Your personal Security Token generated for the Perfecto Lab
In this step, you select which devices to run on and define other configurations in a configuration file.
- Create a configuration file (ConfigFile.json) as a JSON text file in a known folder (you will need the full path later).
Add the device selection parameters to the configuration file.
If specifying a set of devices.
This example selects two devices - one that is an iOS device of version 9.3 and up (using a regular expression), and one is randomly selected by the plugin.
If specifying a number of random iOS devices
NOTE: If a device has not been explicitly selected (using the deviceName property) or when numOfDevices is used (without explicitly setting platformVersion), the system will automatically select an iOS device with accordance to the minimum iOS version as defined in your application.
Add the application parameters - identifying where the application files are located.
Using the appPath and testAppPath fields - for iOS applications
Save the configuration file that should look something like the following:
You can see a full list of configuration parameters here.
Open a command-line (terminal) window in the folder where you want to execute the plugin.
Execute the plugin using the following command in the command-line window:
Here we also supply the full path to the Configuration File created in step 2. Other configuration parameters (except for device selection) could be added to the command line.
- Select the devices as specified in the Device selection parameters of the configuration file [or a random device if no specification provided].
- Install the application and test apk files onto the device
- Run the test methods (based on the configuration parameters)
- Send output to the console window
- Generate an execution report that can be viewed in the Test analysis with Smart Reporting interface.
The command line parameters can set any of the configuration parameters, except for device selection parameters. For more information on the configuration parameters, see Configuration parameters for the Gradle Plugin.Click here for information on running the Gradle plugin over a proxy connection
If you run the Gradle plugin over a proxy connection, you need to supply the proxy information in form of the following Java parameters when activating the plugin:
- http.proxyHost - IP address of the proxy
- http.proxyPort - IP port used for connection
- http.proxyUser - username for connection to proxy server
- http.proxyPassword - password for connection to proxy server.
For proxies supporting SSL encryption, use the following Java Proxy parameters:
- https.proxyHost - IP address of the proxy
- https.proxyPort - IP port used for connection
- https.proxyUser - username for connection to proxy server
- https.proxyPassword - password for connection to proxy server.
During the execution, the plugin will report on the progress of the execution, and the completion of each test method to the command-line window.Click view sample output
At the end of the execution, a high-level summary report of the completion status for each device used will be presented in the command-line window. The report includes:
Click to view a sample summary reportClick to view a sample error message
- Configuration settings resolution: The configuration file used and the list of the configuration settings for the test run
- Progress notifications as the test is configured, installed, and executed, including notifications of the start and completion of:
- Allocating the device
- Resigning the application
- Installing the application and UI runner files
- Executing the test
- Connecting the video recording
- Completion status for each test method on each device
The following error message appears upon failure to allocate a device:
As part of the summary report, the plugin provides the URL of the single test report (STR) for the execution run. Copy the report URL from the summary report on your console:
- Open the URL in your browser to access the execution report. Here, you can drill down to see the screenshots of the different test method executions and what went wrong, if anything. For more information on Smart Reporting, see the Reporting overview. For details on the STR, see Single test report (STR).
Samples of plugin use
The Perfecto GitHub repository includes different samples that demonstrate how you can use the Perfecto Gradle plugin for the following different modes/configurations:
- defaultAndroidProjectSample: An Android project with the plugin Json config file located in the default place
- localJarSample: An Android project configured to run with the Perfecto plugin jar file locally
- pluginConfigurationSample: An Android project with the cloudURL/security token configured in the build.gradle file
- remoteRunSample: How to run the plugin without the source code, only with .apk files
The following video demonstrates the above procedure.
Also in this section: