Skip to content
DevTest Solutions - 10.1
Documentation powered by DocOps

Property Expressions

Last update March 14, 2017

Properties can store many different types of data. They can also evaluate and store expressions. These expressions can contain any valid Java or JavaScript expressions that BeanShell can evaluate. BeanShell is a Java interpreter environment. Further, these expressions could be string patterns, which give real-looking fake strings, appropriate for most purposes.

For more information about BeanShell, see Using BeanShell in DevTest or www.beanshell.org.

To use a property expression, use one of the following formats:

  • {{=expression}}
    BeanShell is used to evaluate the expression and replace {{expression}} with the result of the evaluation. For example, {{=Math.random()}} evaluates the static Java method and replaces the {{}} construct with the random number that was returned.
  • {{key=expression}}
    Using {{rand=Math.random()}} sets a property rand equal to the random number that was returned, and replaces the {{}} construct with the random number.

You can reference properties by name only in a property expression (that is, without the braces) because they are already defined as properties. If the property is not found, the property expression is returned inside braces to indicate that there is a problem in the expression.

Example

A good way to get some practice with property expressions is to build a simple test case that has a single step: an Output Log Message. This step only writes to a log and displays the response in the Interactive Test Run (ITR) Response tab. Therefore, you can experiment with using property expressions.

The following example uses the multi-tier-combo test case in the examples directory.

Screen capture of multi-tier-combo test case.

This graphic shows our example in the ITR utility.

Screen capture of ITR running multi-tier-combo test case.

This graphic shows the Properties tab in the ITR. The tab that is shown is for the step Get User.

Screen capture of Properties tab in the ITR.

This graphic shows the Test Events tabs in the ITR.

Screen capture of the Test Events tab in the ITR.

Look for the event Property set in the Test Events tab.

Java developers can also take advantage of the BeanShell environment in the JavaScript step to test property expressions.

Was this helpful?

Please log in to post comments.