Scripts within tests and stubs

You can write scripts in HCL OneTest™ API by using the HCL OneTest™ API legacy scripting language, ECMAScript (such as JavaScript), or a third-party scripting language that you install.
You can enter a script in a number of places, such as Function, Decision and Assert actions in tests, and Assert using Function actions in the message editor. These scripts return a value or perform an action (for example, a database update). When writing a script in a Function action, the returned value can be stored in a tag. Scripts in other locations must return a boolean value (true or false), which affects the running or validation of a test. The custom functions you add to a HCL OneTest™ API project are available while using the legacy scripts or ECMAScript.
Note:
  • When you use a scripting language other than legacy, the language's own functions and data types are also available.
  • When you use a scripting language that is not provided by HCL OneTest™ API, the built-in functions and project custom functions are not available.
  • Starting from 9.2.1 onwards, when you use the ECMAScript 5 language, syntax is checked, and invalid code is highlighted.
HCL OneTest™ API provides a number of opportunities for dynamic user interaction, including:
  • Function actions. See Function
  • Guard conditions in a message-based stub. See Input tab
  • Message cases in Message Switch actions. See Message cases.
  • Expressions for Assert, Decision, or Iterate While actions. See Flow actions.

Within the editor, you can right-click and select Test to see the output of the filter expressions by using the current values of any included tags.

Test option

You can also click Test from the editor window, specify temporary values for any tags, and run the test to see the output.

Test button

Test button output

Feedback