Getting Started
IntroductionGetting startedOverviewRunning TestoTests running policyTesto for Hyper-V Guides
Guide 1. The very first testGuide 2. Ubuntu Server InstallationGuide 3. Internet access in virtual machinesTesto for QEMU Guides
Guide 1. The very first testGuide 2. Ubuntu Server InstallationGuide 3. Guest AdditionsGuide 4. ParamsGuide 5. CachingGuide 6. Internet access in virtual machinesGuide 7. Linking up virtual machinesGuide 8. Flash DrivesGuide 9. MacrosGuide 10. If clauseGuide 11. No snapshotsGuide 12. Mouse controlGuide 13. Importing disk imagesGuide 14. JS-selectorsGuide 15. CyclesGuide 16. Macros with declarationsReference
Test scripts general overviewTesto lang basic syntaxVirtual Machine declarationVirtual flash drive declarationVirtual network declarationParamsTests declarationMacrosVirtual Machines ActionsMouse actionsDetecting images on the screenVirtual Flash Drives ActionsConditionsCyclesPossible keyboard key IDsJavascript selectors
Main conceptsBuilt-in global functionsExceptionsClass TextTensorClass ImgTensorClass PointParams
Param declaration
Params let you simplify the test scripts management by naming some string constants as global-visible identifiers. You can use those identifiers to access the string constants in the test scripts.
Param (global string constants) declaration is done with the param
keyword. The declaration has the following syntax:
param <name> <value>
name
- Type: identifier. The name for the param. Must be uniqie.value
- Type: string. Param value.
After the declaration, the param becomes accessible inside test scripts. You can access other params while declaring a new param.
It is also possible to declare params with the --param <param_name> <param_value>
command line arguments. These kind of params are also accessible inside the test srcipts, like the static-declared params.
Command-line argument
param
names must not conflict with the static-declared params' names.
A param is available inside the whole test script. Even if referencing occurs earlier that the declaration.
Once declared, a param could not change its value. An error will be generated if such an attempt is done.
Example
Let's assume that there is a command-line argument --param ISO_DIR /path/to/iso
passed to the Testo interpreter. Then
param param1 "value1" # translates to "value1"
param param2 "${ISO_DIR}/${param1}" # translates to "/path/to/iso/value1"
Special (reserved) params
Some params are reserved and play role of actions default behaviour configuration. Such params let you adjust the default timeouts and intervals in some actions. For example, the default wait
timeout is 1 minute. If you want to change the default timeout value for the wait
action (to 2 minutes for example) you need to do this:
test tmp1 {
my_vm wait "Hello world" # Default timeout is 2m
}
param TESTO_WAIT_DEFAULT_TIMEOUT "2m"
...
test tmp2 {
my_vm wait "Hello world" # Default timeout is 2m
}
Special params could be defined only one time.
Special params fall under the same rules as usual params. For example, it is possible to define a special param with the command line argument (
--param
).
Special Params list
TESTO_WAIT_DEFAULT_TIMEOUT
- default timeout inwait
actions.TESTO_WAIT_DEFAULT_INTERVAL
- default time interval between screen checks inwait
actions.TESTO_CHECK_DEFAULT_TIMEOUT
- default timeout incheck
conditions.TESTO_CHECK_DEFAULT_INTERVAL
- default time interval between screen checks incheck
conditions.TESTO_MOUSE_MOVE_CLICK_DEFAULT_TIMEOUT
- default timeout formouse
actions (if a timeout is applicable).TESTO_PRESS_DEFAULT_INTERVAL
- default time intervals between keys pressings inpress
actions.TESTO_TYPE_DEFAULT_INTERVAL
- default time intervals between keys pressings intype
actions.TESTO_EXEC_DEFAULT_TIMEOUT
- default timeout inexec
actions.TESTO_COPY_DEFAULT_TIMEOUT
- default timeout incopyto
andcopyfrom
actions.
Param referencing
Syntax
To reference a param, the following syntax is used:
"${VAR_REF}"
where VAR_REF
is the param's name.
You could put a param referencing in any part of a string and it will be OK:
"Hello ${VAR_REF}"
Params are avaliable basically in any string in Testo-lang. You could use them inside multiline strings, wait-expression, JS-selections, virtual resources declarations and so on
"""Hello
${VAR_REF}
"""
js """
find_text("${Menu entry}").match_color("${foreground_colour}, "${gray}")
"""
machine my_ubuntu {
...
iso: "${ISO_DIR}/ubuntu_server.iso"
}
You can escape the referencing characters
${
with another dollar sign:$${
Aside from params, you can reference counter values inside for
loops and macro arguments inside macro bodies. The syntax remains the same.
Resolve order
When you're referencing an identifier, its value is resolved in a specific order. If the value is found at any step the algorithm stops:
- If the referenced identifier is a
counter
value inside afor
loop, then the counter's value is returned. - If the referenced idenfifier is an argument value inside a
macro
body, then the argument's value is returned. - If the referenced identifier is a static-declared or a command-line declared
param
, its value is returned. - An error is generated since Testo couldn't find the identifier's value.
You can check that a param is declared with a DEFINED
expression in an if
statement:
if (DEFINED VAR_REF) {
print "var ref is ${VAR_REF}"
} else {
print "var ref is not defined"
}