The CLI Library
The CLI library allows automation of test steps using execution of external programs in a shell. Anything that can be achieved via a command line interface can be done with Provengo using this library (thus the name). A common use case is to invoke external interpreters, such as python, for executing certain test steps.
A simple example
Windows (CMD)
/* @Provengo summon cli */ (1)
bthread('Create a directory and delete it', function () { (2)
cli(["cmd","/c", "mkdir", "myDir"], [0], 50000); (3)
cli(["cmd","/c", "dir"], [0]); (4)
cli(["cmd","/c", "rmdir", "myDir" ], [0]); (5)
});
1 | Summons the CLI library. |
2 | Creates a directory named myDir , set timeout of 5 seconds. |
3 | Verifies that the directory exists. |
4 | Deletes the directory. |
Methods
cli(command, expectedRetCodes, timeout)
Execute the command in the local shell. Check for the expected return codes. The command is executed at the project’s directory (in other words: the workfin directory is the project’s directory).
command
-
An array of strings passed to the command line interpreter of the operating system. The first string in this array is the name of the command and the rest are parameters to this command.
expectedRetCodes
-
An array of integers representing a set of return codes that we expect in normal circumstances.
timeout
-
Specifies how long should Provengo wait for the command before declaring a timeout (in milliseconds). This parameter is optional, and defaults to 10,000 milliseconds.
cliAt(command, workingDir, expectedRetCodes, timeout)
Same as above, but use workingDir
as the working directory for the command.
command
-
An array of strings passed to the command line interpreter of the operating system. The first string in this array is the name of the command and the rest are parameters to this command.
workingDir
-
A path to the directory where
command
should be executed. expectedRetCodes
-
An array of integers representing a set of return codes that we expect in normal circumstances.
timeout
-
Specifies how long should Provengo wait for the command before declaring a timeout (in milliseconds). This parameter is optional, and defaults to 10,000 milliseconds.