50.2 The rc module: Run context API

The run context object rc is an interface to the execution state of the currently running test in QF-Test. Providing this wrapper instead of directly exposing QF-Test's Java API leaves us free to change the implementation of QF-Test without affecting the interface for scripts.

Following is a list of the methods of the run context object rc in alphabetical order. The syntax used is a bit of a mixture of Java and Python. Python doesn't support static typing, but the parameters are passed on to Java, so they must be of the correct type to avoid triggering exceptions. If a parameter is followed by an '=' character and a value, that value is the default and the parameter is optional.

Note Please note that the Groovy syntax for keyword parameters is different from Jython and requires a ':' instead of '='. The tricky bit is that, for example, rc.logMessage("bla", report=true) is perfectly legal Groovy code yet doesn't have the desired effect. The '=' here is an assignment resulting in the value true, which is simply passed as the second parameter, thus the above is equal to rc.logMessage("bla", true) and the true is passed to dontcompactify instead of report. The correct Groovy version is rc.logMessage("bla", report:true).

 
 
void addDaemonLog(byte[] data, String name=None, String comment=None, String externalizename=None)
Add a run log retrieved from a DaemonRunContext to the current run log.
Parameters
data The byte array retrieved via DaemonRunContext.getRunLog().
name An optional name for the daemon log node. If unspecified the ID of the Daemon is used.
comment An optional comment for the daemon log node.
externalizename An optional name to externalize the daemon log and save it as a partial log of a split run log.
 
void addResetListener(ResetListener listener)
Server only. Register a ResetListener within the current run context.
Parameters
listener The Listener that should be added. The listener should implement the interface de.qfs.apps.qftest.extensions.qftest.ResetListener.
 
void addTestRunListener(TestRunListener listener)
Register a TestRunListener with the current run context. In interactive mode and batch mode there is a single, shared run context, so the listener will remain in effect until it gets removed via removeTestRunListener or clearTestRunListeners. In daemon mode, each DaemonRunContext has its own set of listeners. See "Test run listeners" for details about the TestRunListener API.
Parameters
listener The listener to register.
 
String callProcedure(String name, Map parameters=None)

Call a Procedure in a test suite.

Note As a convenience, this method can also be called from an SUT script. Care should be taken however, because the script is executed inside the AWT event dispatch thread, so weird side-effects are possible, though QF-Test does its best to avoid these. If possible, call Procedures from a Server script instead.

Parameters
name The fully qualified name of the Procedure.
parameters The parameters for the Procedure. This should be a dictionary. Its keys and values can be arbitrary values. They are converted to strings for the call.
ReturnsThe value returned from the Procedure through an optional Return node.
 
int callTest(String name, Map parameters=None)

Server only. Call a Test case or Test set in a test suite or an entire test suite.

Parameters
name The fully qualified name of the Test case or Test set.
parameters The parameters for the Test case or Test set. This should be a dictionary. Its keys and values can be arbitrary values. They are converted to strings for the call.
ReturnsThe final state of the execution. Either rc.OK, rc.WARNING, rc.ERROR, rc.EXCEPTION, rc.SKIPPED or rc.NOT_IMPLEMENTED.
 
int callTestAsProcedure(String name, Map parameters=None)

Server only. Call a Test case or Test set in a test suite or an entire test suite but treat it as a procedure call so that an uncaught exception terminates the entire call instead of just the currently executing Test case.

Parameters
name The fully qualified name of the Test case or Test set.
parameters The parameters for the Test case or Test set. This should be a dictionary. Its keys and values can be arbitrary values. They are converted to strings for the call.
ReturnsThe final state of the execution. Either rc.OK, rc.WARNING, rc.ERROR, rc.EXCEPTION, rc.SKIPPED or rc.NOT_IMPLEMENTED.
 
Boolean check(boolean condition, String message, int level=rc.ERROR, boolean report=true, boolean nowrap=false)

Check or "assert" that a condition is true and log a message according to the result.

Parameters
condition The condition to evaluate.
message The message to log. It will be preceded by "Check OK: " or "Check failed: " depending on the result. For the old-style XML or HTML report the message will be treated like a Check node if it starts with an '!' character.
level

The error level in case of failure. The following constants are defined in the run context:

  • rc.OK
  • rc.WARNING
  • rc.ERROR
  • rc.EXCEPTION

If the level is rc.EXCEPTION, a UserException will be thrown if the check fails.

report If true, the check will appear in the report. Only applicable if level <= rc.WARNING.
nowrap If true, lines of the message will not be wrapped in the report. Use for potentially long messages.
ReturnsThe result of the check.
 
Boolean checkEqual(Object actual, Object expected, String message, int level=rc.ERROR, boolean report=true, boolean nowrap=false)

Check or "assert" that an object matches a given value and log a message according to the result. Comparison is done using the == operator.

Parameters
actual The actual value.
expected The expected value.
message The message to log. It will be preceded by "Check OK: " or "Check failed: " depending on the result. In case of failure, the expected and actual values will also be logged.
level

The error level in case of failure. The following constants are defined in the run context:

  • rc.OK
  • rc.WARNING
  • rc.ERROR
  • rc.EXCEPTION

If the level is rc.EXCEPTION, a UserException will be thrown if the check fails.

report If true, the check will appear in the report. Only applicable if level <= rc.WARNING.
nowrap If true, lines of the message will not be wrapped in the report. Use for potentially long messages.
ReturnsThe result of the check.
 
Boolean checkImage(ImageRep actual, ImageRep expected, String message, int level=rc.ERROR, boolean report=true, boolean nowrap=false)

Check or "assert" two given ImageRep (see "The ImageRep class") objects for equality and log a message according to the result. Comparison is done using the equals method of the ImageComparator (see "The ImageComparator interface") of the expected object.

Parameters
actual The actual value ImageRep object.
expected The expected ImageRep object.
message The message to log. It will be preceded by "Check OK: " or "Check failed: " depending on the result. In case of failure, the expected and actual values will also be logged. For the old-style XML or HTML report the message will be treated like a Check node if it starts with an '!' character.
level

The error level in case of failure. The following constants are defined in the run context:

  • rc.OK
  • rc.WARNING
  • rc.ERROR
  • rc.EXCEPTION

If the level is rc.EXCEPTION, a UserException will be thrown if the check fails.

report If true, the check will appear in the report. Only applicable if level <= rc.WARNING.
nowrap If true, lines of the message will not be wrapped in the report. Use for potentially long messages.
ReturnsThe result of the check.
 
Object[] checkImageAdvanced(ImageRep actual, ImageRep expected, String message, String algorithm, int level=rc.ERROR, boolean report=true, boolean nowrap=false)

Check or "assert" two given ImageRep (see "The ImageRep class") objects for equality and log a message according to the result. Comparison is done using the specified algorithm.

Parameters
actual The actual value ImageRep object.
expected The expected ImageRep object.
message The message to log. It will be preceded by "Check OK: " or "Check failed: " depending on the result. In case of failure, the expected and actual values will also be logged. For the old-style XML or HTML report the message will be treated like a Check node if it starts with an '!' character.
algorithm The algorithm to use for the comparison as described in "Details about the algorithm for image comparison".
level

The error level in case of failure. The following constants are defined in the run context:

  • rc.OK
  • rc.WARNING
  • rc.ERROR
  • rc.EXCEPTION

If the level is rc.EXCEPTION, a UserException will be thrown if the check fails.

report If true, the check will appear in the report. Only applicable if level <= rc.WARNING.
nowrap If true, lines of the message will not be wrapped in the report. Use for potentially long messages.
ReturnsAn array with following content:
The result of the check as Boolean.
The result of the check as probability.
The transformed image of the expected image as ImageRep, depending on the algorithm.
The transformed image of the actual image as ImageRep, depending on the algorithm.
Further information where appropriate.
 
void clearGlobals()

Server only. Undefine all global variables.

 
void clearProperties(String group)

Server only. Delete a given set of loaded properties or resources.

Parameters
groupThe group name of the properties or resources.
 
void clearTestRunListeners()
Remove all TestRunListeners from the current run context.
 
String expand(String text)

Expand a string using standard QF-Test variable expansion for $(...) or ${...:...} syntax.

Note Remember to double the '$' signs to avoid expansion before the script is executed (see "Quoting and escaping special characters").

Parameters
text The string to expand.
ReturnsThe expanded string.
 
Object fromServer(String name)

SUT only. Retrieve the value of a global variable in the respective interpreter of QF-Test. For example, you can use it in a Groovy SUT script to fetch the value of a global variable from the Groovy interpreter of QF-Test. If the variable is undefined, a KeyError is raised.

Parameters
name The name of the variable.
ReturnsThe value of the variable.
 
Object fromSUT(String client, String name)

Server only. Retrieve the value of a global variable in the Jython or Groovy interpreter of the SUT. For example, you can use it in a Groovy Server script to fetch the value of a global variable from the Groovy interpreter; of the SUT. If the variable is undefined, a KeyError is raised.

Parameters
client The name of the SUT client.
name The name of the variable.
ReturnsThe value of the variable.
 
Boolean getBool(String varname)
Look up the value of a QF-Test variable, similar to $(varname), and treat it as a boolean in any case.
Parameters
varnameThe name of the variable.
ReturnsThe value of the variable.
 
Boolean getBool(String group, String name)
Look up the value of a QF-Test resource or property, similar to ${group:name}, and treat it as a boolean in any case.
Parameters
groupThe name of the group.
nameThe name of the resource or property.
ReturnsThe value of the resource or property.
 
Exception getCaughtException()

Server only. If the script is run inside a Catch node, the exception that was caught is returned. In all other cases, None is returned.

ReturnsThe caught exception.
 
Component getComponent(String id, int timeout=0, boolean hidden=false)
SUT only. Find a component or a component's sub-item using QF-Test's component recognition mechanism.
Parameters
id The QF-Test ID of the Component node that represents the component in the test suite.
timeout This parameter is ignored and always 0 for SUT scripts that are running on the event dispatch thread of the respective GUI engine because it is not possible to free this thread in a safe way in order to wait for the respective component.
hidden If true, find invisible components as well. Useful for menu items.
Returns The actual Java component. For sub-items, a pair of the form (component, index) is returned, where the type of index depends on the type of the item. For tree nodes it is a javax.swing.tree.TreePath object, for tablecells a pair of the form (row, column) and an integer for all other kinds of items.
Note Column indexes returned are always given in table coordinates, not in model coordinates.
 
List getConnectedClients()
Get the names of the currently connected SUT clients.
Returns A list with the names of the currently connected SUT clients, an empty list in case there are none.
 
Map getGlobalObjects()

Get the global variables bound in the current context.

When working with the objects returned please be aware the properties and methods of the objects may differ slightly when using a different script language than the one used to create the objects.

ReturnsThe global variables of the current context.
 
Properties getGlobals()

Get the global variables bound in the current context together with their values as Strings.

ReturnsThe global variables of the current context with their values as Strings.
 
Map getGroupObjects(String group)

9.0+ Get a set of loaded properties or resources.

When working with the objects returned please be aware the properties and methods of the objects may differ slightly when using a different script language than the one used to create the objects.

Parameters
groupThe group name of the properties or resources.
Returns The variables bound for the given group or null if no such group exists.
 
Integer getInt(String varname)
Look up the value of a QF-Test variable, similar to $(varname), and treat it as an integer in any case.
Parameters
varnameThe name of the variable.
ReturnsThe value of the variable.
 
Integer getInt(String group, String name)
Look up the value of a QF-Test resource or property, similar to ${group:name}, and treat it as an integer in any case.
Parameters
groupThe name of the group.
nameThe name of the resource or property.
ReturnsThe value of the resource or property.
 
Object getJson(String varname, boolean expand=true)
Returns an Object by interpreting the value of a QF-Test variable, similar to $(varname), as JSON serialization.
Parameters
varnameThe name of the variable.
expandWhether to expand the value of the variable recursively. For more information please refer to The expand parameter.
ReturnsThe object by deserializing the variable value.
 
Object getJson(String group, String name, boolean expand=true)
Returns an Object by interpreting the value of a QF-Test resource or property, similar to ${group:name}, as JSON serialization.
Parameters
varnameThe name of the variable.
expandWhether to expand the value of the variable recursively. For more information please refer to The expand parameter.
ReturnsThe object by deserializing the variable value.
 
Object getLastComponent()
SUT only. Get the last component that was addressed by QF-Test for replaying some event, check or miscellaneous operation. Calls to rc.getComponent() have no impact.
ReturnsThe last component addressed by QF-Test.
 
Exception getLastException()
Server only. Get the last exception (caught or uncaught) that was thrown during the test run. In most cases getCaughtException is probably more useful.
ReturnsThe most recent exception that was thrown.
 
Object getLastItem()
SUT only. Get the last item that was addressed by QF-Test for replaying some event, check or miscellaneous operation. Calls to rc.getComponent() have no impact.
ReturnsThe last item addressed by QF-Test.
 
Map getLocalObjects(nonEmpty=false)

9.0+ Get the innermost local bindings of the context, or, within a procedure, the parameters of the procedure call when no local variables (to the procedure) have been set before. Then it can be used with nonEmpty=true to get the parameters of the procedure call and implement something similar to keyword arguments in Jython or Groovy.

In an interactive test run, when in debugging mode, the variables are showing in the bottom (right) panel of the QF-Test window in the table "Variable definitions". The innermost local bindings will be found on the first row of the table in case of nonEmpty=false and with nonEmpty=true on the first one where the number of definition is greater zero or when it is a procedure call.

When working with the objects returned please be aware the properties and methods of the objects may differ slightly when using a different script language than the one used to create the objects.

Parameters
nonEmpty True to get the first non-empty set of bindings, false to get the innermost bindings even when empty.
ReturnsThe innermost local variable bindings of the current context.
 
Properties getLocals(nonEmpty=false)

Get the innermost local bindings of the context, or, within a procedure, the parameters of the procedure call when no local variables (to the procedure) have been set before. Then it can be used with nonEmpty=true to get the parameters of the procedure call. Similiar to getLocalObjects, but with the values as String.

In an interactive test run, when in debugging mode, the variables are showing in the bottom (right) panel of the QF-Test window in the table "Variable definitions". The innermost local bindings will be found on the first row of the table in case of nonEmpty=false and with nonEmpty=true on the first one where the number of definition is greater zero or when it is a procedure call.

Parameters
nonEmpty True to get the first non-empty set of bindings, false to get the innermost bindings even when empty.
ReturnsThe innermost local variable bindings of the current context as Strings.
 
Number getNum(String varname)
Look up the value of a QF-Test variable, similar to $(varname), and treat it as a number, i.e. as int or float for Jython and as Integer or BigDecimal for Groovy.
Parameters
varnameThe name of the variable.
ReturnsThe value of the variable.
 
Number getNum(String group, String name)
Look up the value of a QF-Test resource or property, similar to ${group:name}, and treat it as a number, i.e. as int or float for Jython and as Integer or BigDecimal for Groovy.
Parameters
groupThe name of the group.
nameThe name of the resource or property.
ReturnsThe value of the resource or property.
 
Object getObj(String varname, boolean expand=true)

9.0+ Look up the value of a QF-Test variable, similar to $(varname), and return the object stored in the variable.

When working with the objects returned please be aware the properties and methods of the objects may differ slightly when using a different script language than the one used to create the objects.

Parameters
varnameThe name of the variable.
expandWhether to expand the value of the variable recursively. For more information please refer to The expand parameter.
ReturnsThe object value of the variable.
 
Object getObj(String group, String name, boolean expand=true)

9.0+ Look up the value of a QF-Test resource or property, similar to ${group:name}, and return the object stored in the property.

When working with the objects returned please be aware the properties and methods of the objects may differ slightly when using a different script language than the one used to create the objects.

Parameters
groupThe name of the group.
nameThe name of the resource or property.
expandWhether to expand the value of the variable recursively. For more information please refer to The expand parameter.
ReturnsThe object value of the resource or property.
 
Object getOption(String name)
Get an option value at run time. This method is provided more for the sake of completeness, you will probably not need it. For the obvious use case of restoring the value of an option to its previous value after a change with setOption you should use unsetOption instead because values set at script level hide values set interactively in the options dialog. For temporary changes to an option best use pushOption / popOption.
Parameters
nameThe name of the option, a constant from the Options class which is automatically imported in Jython and Groovy scripts. The names of the options that can be read in this way are documented in "Options".
Returns The current value of the option.
 
Object getOverrideElement(String id)
SUT only. Get the overridden target GUI element for the given ID.
Parameters
idThe QF-Test ID or SmartID previously used to override the GUI element.
ReturnsThe GUI element previously registered for the given ID. None/null if no GUI element was registered or the element is no longer valid.
 
Pattern getPattern(String varname, boolean expand=true)
Look up the value of a QF-Test variable and treat it as a regular expression. The difference to rc.getStr and rc.getInt is that they will return a string, respectively an integer value, whereas rc.getPattern will return a Java pattern object. Sample for comparing a string value with a given regular expression: rc.check(rc.getPattern("myRegExp") .matcher(rc.getStr("myString")).matches(), "sample check")
Parameters
varnameThe name of the variable.
expandWhether to expand the value of the variable recursively. For more information please refer to The expand parameter.
ReturnsA Java pattern object with the value of the variable as regular expression.
 
Pattern getPattern(String group, String name, boolean expand=true)
Look up the value of a QF-Test resource or property and treat it as a regular expression. The difference to rc.getStr and rc.getInt is that they will return a string, respectively an integer value, whereas rc.getPattern will return a Java pattern object. Sample for comparing a string value with a given regular expression: rc.check(rc.getPattern("groupname", "myRegExp") .matcher(rc.getStr("myString")).matches(), "sample check")
Parameters
groupThe name of the group.
nameThe name of the resource or property.
expandWhether to expand the value of the variable recursively. For more information please refer to The expand parameter.
ReturnsA Java Pattern-Object with the value of the resource or property as regular expression.
 
Properties getProperties(String group)

Get a set of loaded properties or resources together with their values as Strings.

Parameters
groupThe group name of the properties or resources.
Returns The variables bound for the given group together with their values as Strings or null if no such group exists.
 
String getPropertyGroupNames()
List all available property group names defined by the user. Names are returned in alphabetic order.
Returns A string listing all the names of all user defined property groups. Names are sorted alphabetically and separated by newlines.
 
String getStr(String varname, boolean expand=true)
Look up the value of a QF-Test variable and treat it as a string. In Jython scripts, it has the advantage that it will avoid problems with '\u' sequences that Jython tries to interpret as Unicode constants and fail if the syntax is not correct (see also Jython strings and character encodings).
Parameters
varnameThe name of the variable.
expandWhether to expand the value of the variable recursively. For more information please refer to The expand parameter.
ReturnsThe value of the variable as String.
 
String getStr(String group, String name, boolean expand=true)
Look up the value of a QF-Test resource or property and treat it as a string. In Jython scripts, it has the advantage that it will avoid problems with '\u' sequences that Jython tries to interpret as Unicode constants and fail if the syntax is not correct (see also Jython strings and character encodings)
Parameters
groupThe name of the group.
nameThe name of the resource or property.
expandWhether to expand the value of the variable recursively. For more information please refer to The expand parameter.
ReturnsThe value of the resource or property as String.
 
VariableData getWrapped(String name, boolean expand=true)

Returns the wrapper object of a QF-Test variable of the type VariableData. Besides the actual object value of the variable, it holds additional information about its encryption status and serialization support.

Use this methode if you want to pass on an encrypted variable inside a script without decrypting it.

Parameters
nameThe name of the resource or property.
expandWhether to expand the value of the variable recursively. For more information please refer to The expand parameter.
ReturnsWrapper object of the resource or property as VariableData.
 
VariableData getWrapped(String group, String name, boolean expand=true)

Returns the wrapper object of a QF-Test variable of the type VariableData. Besides the actual object value of the variable, it holds additional information about its encryption status and serialization support.

Use this methode if you want to pass on an encrypted variable inside a script without decrypting it.

Parameters
groupThe name of the group.
nameThe name of the resource or property.
expandWhether to expand the value of the variable recursively. For more information please refer to The expand parameter.
ReturnsWrapper object of the resource or property as VariableData.
 
String id(String id)
Return the QF-Test ID of a specified component. This method should be used to take care that this QF-Test component ID becomes updated when moving or changing the QF-Test ID of the referenced component.
Parameters
idThe QF-Test component ID.
ReturnsThe QF-Test component ID.
 
boolean isOptionSet(String name)
Test whether an option has been set at script level.
Parameters
nameThe name of the option, a constant from the Options class which is automatically imported in Jython and Groovy scripts. The names of the options that can be read in this way are documented in "Options".
Returns True if the option has been set, false otherwise.
 
boolean isResetListenerRegistered(ResetListener listener)
Server only. Checks if a ResetListener is registered.
Parameters
listener The ResetListener to check, if it is registered.
Returns True if the ResetListener has been registered, otherwise False.
 
void logDiagnostics(String client)
Server only. Adds event information stored in the SUT for possible error diagnosis to the run log.
Parameters
clientThe name of the SUT client from which to get the information.
 
void logError(String msg, boolean nowrap=false)
Add a user-defined error message to the run log.
Parameters
msgThe message to log.
nowrap If true, lines of the message will not be wrapped in the report. Use for potentially long messages.
 
void logImage(ImageRep image, String title=None, boolean dontcompactify=false, boolean report=false)
Add an ImageRep (see "The ImageRep class") object to the run log.
Parameters
imageThe ImageRep object to log.
title An optional title for the image.
dontcompactify If true, the message will never be removed from a compact run log.
report True to log the image in the report (implies dontcompactify).
 
void logMessage(String msg, boolean dontcompactify=false, boolean report=false, boolean nowrap=false)
Add a plain message to the run log.
Parameters
msgThe message to log.
dontcompactifyIf true, the message will never be removed from a compact run log.
reportIf true, the message will appear in the report.
nowrap If true, lines of the message will not be wrapped in the report. Use for potentially long messages.
 
void logWarning(String msg, boolean report=true, boolean nowrap=false)
Add a user-defined warning message to the run log.
Parameters
msgThe message to log.
reportIf true (the default), the warning will be listed in the report. Set this to false to exclude this specific warning from the report.
nowrap If true, lines of the message will not be wrapped in the report. Use for potentially long messages.
 
void overrideElement(String id, Component com)
SUT only. Override the target GUI element for component recognition for an element with the given ID. When that QF-Test ID or SmartID is referenced, QF-Test ignores all associated information and directly returns the given element.
Invalidated components are unregistered automatically.
Parameters
idThe QF-Test ID or SmartID of the GUI element to override.
com The GUI element to return as the resolved target. None/null to revert to the default mechanism.
 
void popOption(String name)

Negates a preceding call to pushOption.

Parameters
nameThe name of the option to unset, a constant from the Options class which is automatically imported in Jython and Groovy scripts. The constants for options that can be set in this way are documented in "Options".
 
void pushOption(String name, object value)

Set an option value at runtime, similar to setOption. In contast to the latter, the preceding value is saved for each nested call and can be restored via popOption. The pushOption and popOption calls, which are best placed into a Try / Finally combination, are ideal for temporarily changing an option value without negating a preceding setOption call.

Parameters
nameThe name of the option, a constant from the Options class which is automatically imported in Jython and Groovy scripts. The names of the options that can be set in this way are documented in "Options".
value The value to set, typically a boolean, a number or a constant from the Options class for options edited via a drop-down list. For hotkey options like the hotkey for pausing test run ("Don't Panic" key) this value should be a string like "F12" or "Shift-F6". Supported modifiers are "Shift", "Control" or "Ctrl", "Alt" and "Meta" and combinations thereof. Key specifiers are prepended with "VK_" and then looked up in the class java.awt.event.KeyEvent. Case is irrelevant for both, so "shift-alt-enter" will work as well.
 
void removeResetListener(ResetListener listener)
Server only. Remove a ResetListener.
Parameters
listener The ResetListener to remove.
 
void removeTestRunListener(TestRunListener listener)
Remove a TestRunListener from the current run context.
Parameters
listener The listener to remove.
 
void resetDependencies(String namespace=None)
Completely reset the dependency stack without executing any cleanup.
Parameters
namespace An optional namespace to reset the dependencies for.
 
void resolveDependency(String dependency, String namespace=None, Map parameters=None)
Resolve a Dependency.
Parameters
dependency The fully qualified name of the Dependency to resolve.
namespace An optional namespace to resolve the Dependency in.
parameters The parameters for the Dependency. This should be a dictionary. Its keys and values can be arbitrary values. They are converted to strings for the call.
 
void returnValue(object value)
9.0+Returns from the current procedure returning the given value.
Parameters
value An arbitrary value for the variable. NoteWhen returning a value from a SUT script, the object will be serialized. If this representation needs more than 25 MB of RAM, the String value of the object will be transmitted instead.
 
void rollbackAllDependencies()
Unroll the dependency stacks in all namespaces. This is done in reverse order of their initialization, except for the one in the general name space, which will always be unrolled last.
 
void rollbackDependencies(String namespace=None)
Unroll the dependency stack.
Parameters
namespace An optional namespace to unroll the dependencies in.
 
void setGlobal(String name, object value)
Define a global QF-Test variable.
Parameters
nameThe name of the variable.
value An arbitrary value for the variable. A value of None unsets the variable. NoteWhen accessing the variable from a SUT script, the object will be serialized. If this representation needs more than 25 MB of RAM, the String value of the object will be transmitted instead.
 
void setGlobalJson(String name, Object value)
Define a global QF-Test variable by serializing the given value to a JSON string.
Parameters
nameThe name of the variable.
value An arbitrary value for the variable. It is automatically stringified into a JSON string. A value of None unsets the variable.
 
void setGroupObject(String group, String name, Object value)
9.0+Set the value of an object (resource or property) in a group.
Parameters
group The name of the group. A new group is created automatically if necessary.
nameThe name of the object, e.g the resource or property.
value An arbitrary value for the object (also named "property"). A value of None unsets the object.
Note This method also works for the special groups 'env' and 'system'. This way, environment variables or system properties can be defined. Values in other special groups (like 'qftest') can usually not be overridden. In that case, a ReadOnlyPropertyException is thrown.
Note Alias of setProperty.
 
void setLocal(String name, Object value)
Define a local QF-Test variable.
Parameters
nameThe name of the variable.
value An arbitrary value for the variable. A value of None unsets the variable. NoteWhen accessing the variable from a SUT script, the object will be serialized. If this representation needs more than 25 MB of RAM, the String value of the object will be transmitted instead.
 
void setLocalJson(String name, Object value)
Define a local QF-Test variable by serializing the given value to a JSON string.
Parameters
nameThe name of the variable.
value An arbitrary value for the variable. It is automatically stringified into a JSON string. A value of None unsets the variable.
 
void setOption(String name, object value)

Set an option value at run time. Any value thus set overrides the value read from the system configuration file or set via the option dialog, but is never shown in the option dialog or saved to a configuration file. The default value can be restored via unsetOption. The value of a possibly preceding call to setOption gets overwritten. In case that value should be restored, pushOption / popOption must be used instead.

Parameters
nameThe name of the option, a constant from the Options class which is automatically imported in Jython and Groovy scripts. The names of the options that can be set in this way are documented in "Options".
value The value to set, typically a boolean, a number or a constant from the Options class for options edited via a drop-down list. For hotkey options like the hotkey for pausing test run ("Don't Panic" key) this value should be a string like "F12" or "Shift-F6". Supported modifiers are "Shift", "Control" or "Ctrl", "Alt" and "Meta" and combinations thereof. Key specifiers are prepended with "VK_" and then looked up in the class java.awt.event.KeyEvent. Case is irrelevant for both, so "shift-alt-enter" will work as well.
 
void setProperty(String group, String name, object value)
Set the value of a resource or property in a group.
Parameters
group The name of the group. A new group is created automatically if necessary.
nameThe name of the resource or property.
value An arbitrary value for the property. A value of None unsets the property.
Note This method also works for the special groups 'system' and 'env' and can be used as a means to set environment variables and system properties. Values in other special groups like 'qftest' mostly cannot be set or changed that way, trying to do so triggers a ReadOnlyPropertyException.
 
void skipTestCase()
Stop the execution of the current test case and mark it as skipped.
 
void skipTestSet()
Stop the execution of the current test set and mark it as skipped.
 
void stopTest()
Terminate the current test run.
 
void stopTestCase(boolean expectedFail=false)
Stop the execution of the current test case.
Parameters
expectedFailIf true, mark possible errors in this test case as expected failures.
 
void stopTestSet()
Stop the execution of the current test set.
 
void syncThreads(String name, int timeout, int count=-1, boolean throw=true, int remote=0)
Server only. Synchronize a number of parallel threads for load testing. The current thread is blocked until all threads have reached this synchronization point or the timeout is exceeded. In the latter case, a TestException is thrown or an error logged.
Parameters
nameAn identifier for the synchronization point.
timeoutThe maximum time to wait in milliseconds.
count The number of threads to wait for. Default value -1 means all threads in the current QF-Test instance.
throw Whether to throw an exception (default) or just log an error if the timeout is exceeded without all threads reaching the synchronization point.
remote The number of QF-Test instances - potentially running on different machines - to synchronize. Default 0 means don't do remote synchronization.
 
void toServer(...)

SUT only. Set some global variables in the respective interpreter of QF-Test. For example, you can use it from a Groovy SUT script to set global variables in in the Groovy interpreter of QF-Test.

Each argument can be any of:

A string
This is treated as the name of a global variable in the local interpreter. The variable by the same name in QF-Test's interpreter is set to its value.
A dictionary with string keys
For each key in the dictionary, a global variable by that name is set to the corresponding value from the dictionary.
A keyword argument in the form name=value
The global variable named name is set to value.
 
void toSUT(String client, ...)

Server only. Set some global variables in the respective interpreter of the SUT. For example, you can use it from a Groovy Server script to set global variables in in the SUT Groovy interpreter.

Except for client, each argument can be any of:

A string
This is treated as the name of a global variable in the local interpreter. The variable by the same name in SUT's interpreter is set to its value.
A dictionary with string keys
For each key in the dictionary, a global variable by that name is set to the corresponding value from the dictionary.
A keyword argument in the form name=value
The global variable named name is set to value.
Parameters
client The name of the SUT client.
 
void unsetOption(String name)

Restore an option value by removing a possible override from a previous call to setOption.

Parameters
nameThe name of the option to unset, a constant from the Options class which is automatically imported in Jython and Groovy scripts. The constants for options that can be set in this way are documented in "Options".
 
RunContext withDefault(Object defaultResult)
9.0+Creates a new run context object, for which reading access on a non-existing variable or preoprty/resource in a group does not trigger a UnboundVariableException or MissingPropertyException. Instead, the defined default result value is returned. All other methods and properties of the rc object behave as unmodified.
Parameters
defaultResultThe object which will be returned if a variable has no value.
Returns A new run context (rc) objekt, which has the given default value set for variable access.
 
 

50.2.1 The expand parameter

The methods getStr, getObj, getInt, getNum, getBool, getPattern and getJson support the optional parameter expand. This parameter controls, whether to expand the value of the variable recursively, which means whether to treat substrings of the String value of the variable value which happen to have the QF-Test variable syntax $(somecharacters) as a variable to be expanded or as simple text. If the parameter is omitted or null, the replacement is performed (recursively) if and only if the variable value is a String. To avoid probems, some strings, e.g. the return value of a Fetch text step, the client output from the special group ${qftest:client.output.<name>} or the result of the standard procedure qfs.utils.readTextFromFile, are also not automatically expanded, but only if the expand parameter is explicitely set to true.

Note that if you want to set this parameter, you must use Python keyword syntax to avoid conflicts e.g. with getStr(String group, String name), i.e. rc.getStr("var", expand=0) instead of rc.getStr("var", 0) - otherwise the property 0 would be taken from the group var .

Sample

Given the QF-Test variables and values

Variable referencevalue
$(simplevar)foo
$(nestedvar)A value: $(simplevar)
${group:var}A value: $(simplevar)
Table 50.1:  QF-Test variables for the expand parameter sample below

the parameter expand has the following effect:

print rc.getStr("nestedvar", expand=True)  # "A value: foo"
                print rc.getStr("nestedvar", expand=False) # "A value: $(simplevar)"
                print rc.getStr("group", "var", True)      # "A value: foo"
                print rc.getStr("group", "var", False)     # "A value: $(simplevar)"
Example 50.4:  Usage of the expand parameter (Jython script)