Page tree
Skip to end of metadata
Go to start of metadata

 

The Perfecto Gradle Plugin allows the tester to -

  • Select a device or multiple devices from the Perfecto Lab to run Tests of mobile applications using either Android instrumentation or Apple XCTest/XCUITest.
  • Install the application and test files onto the selected devices.
  • Run the test methods on the devices.
  • See the progress of the test set on the console.
  • Access a DigitalZoom Report Library grid that presents the results of the tests.

The procedure presented here is used when the application and test files are available on the local disc storage and the plugin jar file is not installed.

What do we need to do

Executing the plugin, when not using an Android Studio project, is performed as follows

  1. Create a new build.gradle file.

  2. Add the lines to the build gradle file that define the location of the plugin library and the dependency on the plugin:

    3a. To configure Gradle to automatically locate and download the plugin library add the following lines to build.gradle file:

    buildscript {
        repositories {
            jcenter()
            maven {
                url "http://repository-perfectomobile.forge.cloudbees.com/public/"
            }
        }
     
        dependencies {
            classpath "com.perfectomobile.instrumentedtest.gradleplugin:plugin:+"
        }
    }

    3b. If the plugin library is already downloaded to a folder (for example: libs sub-folder) add the following lines to build.gradle file:

    buildscript {
        repositories {
            jcenter()
     
    		flatDir dirs: 'libs'
        }
     
        dependencies {
            classpath "com.perfectomobile.instrumentedtest.gradleplugin:plugin:+"
        }
    }

     

     

     

  3. Add the line that defines the plugin task 

    apply plugin: 'com.perfectomobile.instrumentedtest.gradleplugin'
  4. Add the plugin configuration settings - Lab authentication parameters
    1. Include the URL for the Perfecto Lab
    2. Your personal Security Token, generated for the Perfecto Lab

      perfectoGradleSettings { 
          cloudURL "mobilecloud.perfectomobile.com" 
          securityToken "AAABNg0ODAoPeNqtkT1PwzAQhnf/CkssM...JxQ3HEI8NsX02ff" 
      } 

      Note: You could also supply the configuration file location parameter in this gradle-file clause.

  5. Create a configuration file (ConfigFile.json) as a JSON text file in a known folder (you will need the full path later).
  6. Add the device selection parameters to the configuration file.

    "devices" : [
    	{
    		"platformName" : "Android",
    		"platformVersion": "^[678].*",
    		"manufacturer" : "Samsung"
    	},
    	{}
    ]

    This example selects two devices - one that is a Samsung phone running Android 6.* or 7.* or 8.* (uses a regular expression), and one is randomly selected by the plugin.

  7. Add the reporting parameter settings, to add tags to the DigitalZoom execution report.

    "tags" : ["plugin", "espresso", "demo"],
    "projectName": "playground",
    "projectVersion": "1.5",
    "jobName": "newFeature",
    "jobNumber": "45",
  8. Add the application parameters - identifying where the apk files are located.

    1. apkPath and testApkPath - for Android applications
    2. appPath and testAppPath - for iOS applications

      "testApkPath": "C:/User/myuser/AndroidStudioProjects/Playground/app/build/outputs/apk/app-debug-AndroidTest.apk",
      "apkPath": "C:/User/myuser/AndroidStudioProjects/Playground/app/build/outputs/apk/app-debug.apk"

      You can supply additional parameters if you need to limit the test application to only execute specific methods or classes.

  9. Save the configuration file that should look something like the following:

    {
    	"devices" : [
    		{"deviceName" : "FA6BR0304878"},
    		{
    			"platformName" : "Android",
    			"platformVersion": "^[678].*",
    			"manufacturer" : "Samsung"
    		},
    		{}
    	],
    	"testApkPath": "C:/User/myuser/AndroidStudioProjects/Playground/app/build/outputs/apk/app-debug-AndroidTest.apk",
    	"apkPath": "C:/User/myuser/AndroidStudioProjects/Playground/app/build/outputs/apk/app-debug.apk",
     
    	"tags" : ["plugin", "espresso", "demo"],
    	"projectName": "playground",
    	"projectVersion": "1.5",
    	"jobName": "newFeature",
    	"jobNumber": "45"
    }
  10. Open a command-line (terminal) window in the folder where you want to execute the plugin. 

  11. 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 steps 5-9. Other configuration parameters (except for device selection) could be added to the command line.

    For Android apps
    gradle perfecto-android-inst -PconfigFileLocation="C:\temp\Espresso\ConfigFile.json"
    For iOS apps
    gradle perfecto-xctest -PconfigFileLocation="C:\temp\Testing\ConfigFile.json"


    This will
     - 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 DigitalZoom Reporting interface.

     

  12. 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.
  13. 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
  14. Copy the report URL from the summary report on your console:

    View the detailed report at: https://demo.reporting.perfectomobile.com/library?startExecutionTime[1]=lastMonth&tags[0]=5af27a82-54cc-405a-8c6e-fa46fcae874b 
    Finished flow execution
  15. Open the URL in your browser to access the execution report: