Developers » Reference Tools » Unit Tests » Create New Unit Test


Create New Unit Test

To create a new unit test:

  1. Go to Setup > Development > Scripts and select the Script option from the New menu, or click the Create New link from the instructional text on the Scripts workspace.

  2. Complete the form fields:
    • Name: Enter a name.

    • Script Type: Select Unit Test.
    • System ID: A unique identifier, automatically generated when you name an object. You can use this identifier to reference an object in scripts, templates, tags, and through the API. You can change the System ID by selecting the pencil icon. Use caution when changing the ID as it can affect existing scripts associated with the object. For more information, see System ID.

    • Test for Script: Enter the name script you will test.

      Workflow generates the test code that will execute the script, and displays it in the Code window. You can modify this code if necessary.

      Warning: If you change the Test for Script value, Workflow will generate the code for the new script, but does not remove the code for the former script. 

    • Description: Add a brief description. This is used as an internal note for administrators.
  3. Edit the code in the code window to include your assertion method(s) and other context initialization methods as necessary. See Assertion Methods for more information.

  4. Use the reference tools on the right side of the workspace to look up information.
    • Custom Objects: Select a custom object from the list to display a list of methods and objects that are available for these integrations:

      • SAP CPQ
      • NIPR
      • SAP Commissions
      • SAP legacy True Producer
    • Find System ID: Select an object from one of the entities and Workflow will display the related object with a link that enables you to edit the object. Some objects, such as custom fields with predefined values, custom tables, and table controllers, will show additional information about that object, in addition to the object name and system ID.
    • Look up System ID: Select an entity and enter the system ID to see the object name. For some objects, Workflow displays the object with a link that enables you to edit the object.
    • Custom Params: Displays a list of all custom parameters and values that have been added in Workflow.

      Important: For security reasons, password custom parameters are not displayed in this area.

    • Context Info: Displays objects and methods that you can use in the code. Click the icon to expand the categories. The available objects are based on the script type selected. See Workflow API Documentation for more information.
    • Select Script Test Data: Complete the fields and select Update Script. Workflow will update the code based on your script test data. This is useful to insert case or user information that you can use to test your script.
  5. Select Debug to open the Debug Tool. See Debug Tool for more information.

  6. Select Save to add the new unit test.

  7. Select Run Test to validate the script.

Workflow displays the results of the test in the Results tab and displays detailed information about the results in the Output tab.