This repository contains the code of our on-computer test recorder that works with TOLLER. The program records UI traces (that consist of UI hierarchies interleaving with actions) to reflect the testing process. It does not matter who operates the target app--both humans and automated tools can record with this program.
You can download our prebuilt binary from here.
To build by yourself, import this repo with some IDE (e.g., JetBrains IntelliJ Idea) and follow its instructions to generate a JAR archive. All dependent libraries are available in lib/.
You should have TestRecorder.jar in the root directory of this repo after this step. If you want to record traces during testing using TOLLER's experiment framework, place this repo in the test-recorder folder in the root directory of TOLLER's repo.
To quickly start recording:
$ CTRL_PORT={CTRL_PORT} SKIP_MINICAP=1 java -jar TestRecorder.jar {OUT_DIR}Replace CTRL_PORT with the ADB-forwarded port number to reach TOLLER (see here for how). Also replace OUT_DIR with the path to the directory where you want to store UI hierarchies. As you operate on the target app, you will see many JSON files in OUT_DIR, each consists of a UI hierarchy and the action observed on it.
Note that the aforementioned command does not record screenshots. If you need screenshots, use the following command:
$ CTRL_PORT={CTRL_PORT} MINICAP_PORT={MINICAP_PORT} java -jar TestRecorder.jar {OUT_DIR} {SCREEN_OUT_DIR}Replace MINICAP_PORT with the ADB-forwarded port number to reach Minicap (see here for how). Also replace SCREEN_OUT_DIR with the path to the directory where you want to store screenshots.
The test recorder accepts a set of environment variables as configs:
-
XPATHS_TO_KILLspecifies which UI elements to disable and which UI screens to restart the target app on during recording. You can generate this value with:$ python3 get-source-xpath.py JSON_UI_1 [JSON_UI_2 ...]
Each
JSON_UIargument corresponds to the path to a JSON file from the test recorder from a previous run. -
RETAIN_CRASH_HANDLERspecifies whether the app's default crash handler should be preserved. Set this to1to activate this feature. -
APP_RESTART_COMMANDspecifies the command to execute when the recorder decides to restart the target app. Note that this command will be executed on the computer instead of the test device. -
WATCHDOG_INTVspecifies the interval between two progress checks performed by the watchdog. The watchdog will restart the test device after 3 consecutive failed checks (i.e., when the recorder has not received any new action). Unset this environment variable to disable this feature. -
DEV_RESTART_COMMANDspecifies the command to execute when the recorder decides to restart the test device. Only effective whenWATCHDOG_INTVis set. Note that this command will be executed on the computer instead of the test device. -
DONT_KILL_AFTERspecifies when the watchdog should stop after recording starts. Only effective whenWATCHDOG_INTVis set.