How to Pass a Value to a Test Runtime
In case when it is required to pass some values to a test in command line, it is possible to do it like this:
- In AUT VM arguments pass desired parameters as Java properties, i.e. add arguments:
-DpropertyName=propertyValue
- Use ECL command
substitute-variables
(which usesorg.eclipse.core.variables
plugin) to get a property value:
// writes prop val to AUT workspace log
log [substitute-variables "${system_property:propertyName}"]
With aid of variables and user-defined procedures variables and user-defined procedures, this becomes even more convenient:
- Create ECL context which consist of only one command, declaring global variables:
global [val prop1 [substitute-variables "${system_property:prop1}"]] [val prop2 [substitute-variables "${system_property:prop2}"]] [val prop3 [substitute-variables "${system_property:prop3}"]]
- Add this ECL context to project’s default contexts in Project Settings
- Access these properties in any ECL using $-syntax:
concat $prop1 $prop2 $prop3 | show-alert
Important
When AUT does not include org.eclipse.core.variables
plugin and hence command substitute-variables
fails, it is still possible to use get-java-property
to get JVM system property value.