UICondcutor Command Line interface - google/android-uiconductor GitHub Wiki

UICD-cli is another way of re-running your test cases.

Once you have your test workflows ready in the form of json files, you can use them to run the tests through the uicd command line interface (UICD-cli).

Prerequisite

  • JDK 1.8+ installed
  • Device with Android M and above
  • tar installed to extract script folder

Export UICD test case

To export UICD test cases from the FE, simply right click on the test case of your choice. You can find it in test cases tree on the right side of UICD FE and click export.

NOTE: Once you are done exporting the test cases of your interest, you will need to close the UICD FE window and the backend terminal that started UICD. This is to make sure that the UICD FE daemon server is terminated and UICD CLI can use its new daemon server without any conflicts.

ExportTestCase

Run tests using UICD CLI

  1. Download uicd_cli.tar.gz binary

  2. Create folder.

    cd ~
    ~$ mkdir uicd-cli
    ~$ cd uicd-cli
  3. Extract uicd_cli.tar.gz to uicd-cli folder. The folder structure is as follows:

    tar xvzf ~/Downloads/uicd_cli.tar.gz -C ~/uicd-cli

    TarFileStructure

  4. Copy the exported json test files to folder ~/uicd-cli/uicd-testcases

    cp -r <path/to/your/testcases/dir>/* ~/uicd-cli/uicd-testcases
  5. In folder where you can see the file uicdcli.sh, run the following command:

    ~/uicd-cli$ ./uicdcli.sh -d <device_serial> -i ./uicd-testcases

    IMPORTANT: Make sure you have closed the UICD FE window and the backend terminal that started UICD before running this command. This is to make sure that the UICD FE daemon server is terminated and UICD CLI can use its new daemon server without any conflicts.

  6. You will be able to see the result on command line.

    Uicd Test Start...
    Starting print to file...
    /usr/local/google/home/{{USERNAME}}/uicd-cli/uicd-basepath/output/log/UicdCLIlog1553741247283.txt
    Test(/usr/local/google/home/{{USERNAME}}/uicd-cli/./uicd-testcases/dummytest1) finished.
    Result: PASS
    Writing contents to: /usr/local/google/home/{{USERNAME}}/uicd-cli/uicd-basepath/output/result/dummytest1/action_execution_result
    Starting print to file...
    /usr/local/google/home/{{USERNAME}}/uicd-cli/uicd-basepath/output/log/UicdCLIlog1553741256935.txt
    Test(/usr/local/google/home/{{USERNAME}}/uicd-cli/./uicd-testcases/dummytest2) finished.
    Result: PASS
    Writing contents to: /usr/local/google/home/{{USERNAME}}/uicd-cli/uicd-basepath/output/result/dummytest2/action_execution_result
    ======================Uicd tests final result=========================
    Runs: (2), Failures: (0), Passed: (2).

CLI Options

To give user more control over their test runs, UICD CLI has a set of options that the users can leverage.

usage: uicdCLI [-c <arg>] [-d <arg>] [-g <arg>] [-i <arg>] [-m <arg>] [-o
       <arg>] [-s]
 -c,--config <arg>            Config File Path
 -d,--devices <arg>           Devices Serial Number (Separated by comma if
                              more than one)
 -g,--global_variable <arg>   Global variable (uicd_key1=value1,
                              uicd_key2=value2)
 -i,--input <arg>             Input File/Folder Path
 -m,--mode <arg>              Play Mode (SINGLE|MULTIDEVICE|PLAYALL)
 -o,--output <arg>            Output Folder
 -s,--screen                  Input File/Folder Path

Run multiple tests through CLI simultaneously on separate terminals

If the user wants to open multiple terminals and run their tests through the CLI simultaneously, a few prerequisite steps that they need to perform to be able to do this.

  1. Make sure you are not using the same device_serial in multiple simultaneous test runs. UICD does not take care of any allocation and scheduling of devices and therefore, will lead to unexpected behavior.

  2. UICD CLI forwards device port to local machine during runtime, hence if multiple terminals run the tests using uicdcli.sh simultaneously, it might have port conflict.

    To solve this, we need to create the config file for each device.

    ~/device1.cfg

    adb_forward_start_port=6810
    

    ~/device2.cfg

    adb_forward_start_port=6820
    

    Pass the cfg file to uicdcli.sh using -c option, and now you can run different test cases in different device simultaneously.

    ~/uicd-cli$ ./uicdcli.sh -d <device_serial_1> -i ./uicd-testcases/test1 -c ~/device1.cfg
    ~/uicd-cli$ ./uicdcli.sh -d <device_serial_2> -i ./uicd-testcases/test2 -c ~/device2.cfg
⚠️ **GitHub.com Fallback** ⚠️