Skip to content

Test Task Customization

Nathan Bu edited this page Feb 9, 2023 · 11 revisions

Upload Attachments

In the Runner page, you can upload attachments to a package set.

File Type

Name Desc
Windows App Will be installed by the command like Add-AppxPackage -ForceApplicationShutdown -forceupdatefromanyversion before testing.
Common file Will be loaded to the Load Dir by the chosen Load Type
T2C Json Just used for T2C test.

Load Type

Only work when the File Type is Common file.

Load Dir

Only work when the File Type is Common file and can't be empty. The format should be like firstLevelFolder/secondLevelFolder, and the **firstLevelFolder **will be generate under AgentInstallFolder.

image

Pre-install App

Put the packages of app to AgentInstallFolder/storage/preApp. When the devices plugin in, the packages would be installed. If install failed, the agent main process will be shutdown.

Grant permission

When trigger a test task, you can set up the permissions needed to be grant before testing.

["android.permission.FOREGROUND_SERVICE", "android.permission.FOREGROUND_SERVICE"]

image

Device Action

In the RESTful API, a test task is described thru the TestTaskSpec object, where you can specify the device actions for each test run in the following structure: TestSpecDesign

When triggering a test task, you can customize some actions to set up the devices at different lifecycle stages. image For Example:

{
    "setUp": [{
            "method": "setProperty",
            "args": ["log.tag.WelcomeScreen", "Verbose"]
        }, {
            "method": "setProperty",
            "args": ["log.tag.ConsentDialog", "Verbose"]
        }, {
            "method": "backToHome",
            "args": []
        }
    ],
    "tearDown": [{
            "method": "setProperty",
            "args": ["log.tag.WelcomeScreen", " "]
        }, {
            "method": "setProperty",
            "args": ["log.tag.ConsentDialog", " "]
        }
    ]
}

Push File to Device

{
	"method": "pushFileToDevice",
	"args": ["filePathOnAgent","filePathOnDevice"]
}
  1. filePathOnAgent: It can be an absolute path like D:\file\Copy.ps1, also be a relative path under AgentInstallFolder like temp/111.txt
  2. filePathOnDevice: The file path on device. For example, /sdcard/Movies/testfile/

Pull File from Device

{
	"method": "pullFileFromDevice",
	"args": ["filePathOnDevice"]
}
  1. filePathOnDevice: It can be the path of folder like /sdcard/Movies/testfile/, also can be the path of file like /sdcard/Movies/testfile/aa.log

Customize command

The commands can be configured in application.yml.

  1. type: command type. Only support ADB shell command now.
  2. when: setUp or tearDown. Used to specify the execute timing.
  3. suite-class-matcher: Regular expression. Used to match the suite class of test task.
  4. inline: Command script. Will be executed line-by-line on target device.

For example,

app:
  device-script:
    commands:
      - type: ADBShell
        when: setUp
        suite-class-matcher: '.*'
        inline: |
          rm -rf /sdcard/Movies/testfile2
          mkdir /sdcard/Movies/testfile2
          cp /sdcard/Movies/testfile/*  /sdcard/Movies/testfile2
      - type: ADBShell
        when: tearDown
        suite-class-matcher: '.*'
        inline: |
          rm -rf /sdcard/Movies/testfile2
Clone this wiki locally