Skip to content
DevTest Solutions - 10.1
Documentation powered by DocOps

Scripted Assertion

Last update March 10, 2016

The Scripted Assertion assertion lets you write and run scripts. The result must be a Boolean, or false is returned.

Complete the following fields:

  • Name
    Defines the name of the assertion.
  • If
    Specifies the behavior of the assertion from the drop-down list.
  • then
    Specifies the step to which to redirect if the assertion fires.
  • Log
    Identifies event text to print if the assertion fires.

Click Run Assertion to execute the assertion.

  • Language
    Designates the scripting language to use.
    Values:
    • Applescript (for OS X)
    • Beanshell
    • Freemarker
    • Groovy
    • JavaScript
    • Velocity
    Default: Beanshell
    To use additional scripting languages, see Enabling Additional Scripting Languages.
  • Copy properties into scope
    Allows you to specify which properties to download for use in the step.
    Values:
    • Test state and system properties: all properties for the test case and system
    • Test state properties: properties that provide information about the test case
    • TestExec and logger only: only the TestExec and logger properties
    Default: Test state properties

Enter your script into the script editor on the left.

All the objects available for use in the script editor are listed in the Available Objects panel on the right. The list includes primitive types of data (strings and numbers) and objects such as EJB response objects that were executed in the test case. Double-click an entry in the Available Objects table to paste that variable name into the editor area.

Click Test to open a window with the result of the script execution or a description of the errors that occurred.

When you save the test case, the assertion is checked for syntax errors.

Some things to remember:

  • If you use a property - {{someprop}} - in a script, it is substituted for the property value at run time before the script is executed.
  • If you need access to a property with a "." in the name, such properties are imported into the script environment replacing "." with "_". So {{foo.bar}} in a script is the same as foo_bar.
  • You can produce a DevTest log event inside a script step or assertion by using the testExec object. To produce a DevTest log event, code the following line, as opposed to using the log4j logger. The testExec.log() method causes an actual DevTest event to be raised. You can see the event in the ITR.

    testExec.log("Got here");

Was this helpful?

Please log in to post comments.