Testing a script expression

A script expression is a brief JavaScript program used to calculate the value of a flow element property. Even though users can enter a script expression in a property editor dialog within Switch, they still need a SwitchScripter to test a complex script expression:


  1. Create a new empty script package and save it with an appropriate name in an appropriate location.
  2. Enter the script expression in the JavaScript tab of the Program pane (leave the default entry points in place but it is cleaner to remove them).
  3. In the Fixture pane, configure the basic fixture settings and at least one incoming job to reflect a relevant test scenario. If the script expression accesses information in the internal job ticket of its job, setup the corresponding test data as well.
  4. Select the desired job in the Fixture pane (make sure it is enabled), select "script expression" in the entry point selector in the toolbar, and click the "Invoke entry point with the test fixture" tool button. The selected job is passed to the script expression's predefined "job" variable.
  5. In the Messages pane, review the message issued by SwitchScripter containing the result of evaluating the script expression. Use the Environment.log() and Job.log() functions to generate messages for debugging.
  6. If desired, adjust the script expression and start over.
  7. Once the script expression works correctly, copy/paste it into the appropriate property editor dialog within Switch.