Custom Modules

Document created by Chris Sommerstad Employee on Jul 21, 2017
Version 1Show Document
  • View in full screen mode

Using a Custom Module users can call Java JAR files from within CloudTest using a CloudTest script written in JavaScript.

Prerequisites

The Custom Module feature permits users to create and add their own Java custom modules (such as a Jar file) to a CloudTest environment. The Java Custom Module engine supports JAR files built using Java 7 and earlier.

Note:  In the real world, you'll create your own Java jar to use. For demonstration purposes, the remainder of this article will use the open source project Barbecue. The Barbecue open source project generates bar codes. This example creates a Java object, and then calls a couple of methods on it. The created object represents a barcode, and the calls get and change the label on that barcode.

Uploading a Custom Module

Once you have selected a jar to use, open your CloudTest instance and use the steps to add it to your repository.

Note: This feature is enabled per license. If you don't see Custom Modules ask your SOASTA representative. This feature is not available in CloudTest Lite.

  1. Navigate to Central > Custom Modules (under the Library node).

  1. Click the New icon.

Use the New Custom Module box for the remaining steps.

  1. In the New Custom Module box, click Choose File to select your Java code file. For example, barbecue-1.5-beta1.jar.
  2. Assign a repository name. This will appear in the Central > Custom Modules list.
  3. Optionally, select a repository folder.

  1. Click OK to complete creation of the Custom Module.

Calling a Custom Module from a CloudTest Script

    1. Next, create a CloudTest script (from Central > Scripts) in your test that will call the new Custom Module.

In this example script, we will need three lines:

    1. An import statement that imports the desired jar file.
    2. A variable for the ID that we are generating, such as barcode.
    3. A line each for the original and the changed barcode object's label that will post a message into the test result using the LEVEL_INFO parameter.

For example:

  1. Save the script before proceeding. Leave the script open in the Script Editor.

Associate the Custom Module with the Script

Next, we will create a binding of this script and the Custom Module we created above.

  1. With the script open in the Script Editor, click the Custom Modules button in the Script Editor.

When you do so, the Custom Modules panel opens on the right.

  1. Click Add Custom Modules.

  1. Use the Choose custom module box to navigate to the custom module created above. For example, /SOASTA Tutorial/Barbecue.
  2. .

  1. Click OK to complete this association. The Custom Module selected is listed in the right panel.

The following screenshot shows an example test result using the Barbecue custom module via this CloudTest script.

For more background information about custom modules, see Custom Sending via Java.

Attachments

    Outcomes