Previous Topic: Specify a PropertyNext Topic: String Patterns


Property Expressions

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. 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.