How do I parameterize a Test Composition (or its components) so that I can change the behavior each time I play it without having to edit it each time?

Document created by DPM Admin on Jul 21, 2017Last modified by Avril Dsilva on Aug 14, 2017
Version 6Show Document
  • View in full screen mode

General methodologies

There are three primary methods that can be used to externally control the behavior of a Test Composition or its components:

  1. Use Global Properties
  2. Use Global Properties and Scripting
  3. Use data that is external to SOASTA CloudTest

In all three schemes, you change the controlling data first, and then play the Test Composition. Internally, the Test Composition changes its behavior based upon the value of the data.

 

Method 1 - Use Global Properties

The simplest method is to define Messages or Browser Actions such that Global Properties are substituted into Messages before they are sent, or into Browser Action requests before they are played. Refer to the question "How do I dynamically or programmatically substitute a value into a Message or Browser Action before ..." for instructions.

Before playing the Test Composition, you change the values of the Global Properties, which will change the values in the Messages or Browser Actions.

Since Scripts in Test Compositions can modify Global Property values, if there are a small number of sets of values that you use regularly, you could create several Test Compositions to set up each of those common sets. You would then run the "setup" Test Composition first, followed by the parameterized Test Composition. Pairs of such Test Compositions could be placed into Playlists.

Refer to the separate question "How do I pass a value from one Test Composition to another?" for more information about defining and using Global Properties.

Refer to the Scripting documentation for information about how to set and retrieve Global Property values from Scripts.

 

Method 2 - Use Global Properties and Scripting

Scripts can read the values of Global Properties to obtain values, or even to accept "commands" that affect the logic of the Script. Before playing the Test Composition, you can change the values of Global Properties that your Scripts interpret to decide what actions to take.

Any Script can traverse the object hierarchy of the Test Composition, find Messages and Browser Actions, and change portions of their message or request. This method allows the highest degree of customization, since you can add complex custom logic to the Script to insert computed values into the Message or Browser Action, adjust custom Script validation, or take any other action that a Script can take.

Refer to the separate question "How do I dynamically or programmatically substitute a value into a Message or Browser Action before ..." for general instructions on how to write a Script that inserts values into a Message or Browser Action.

Refer to the separate question "How do I pass a value from one Test Composition to another?" for more information about defining and using Global Properties.

 

Method 3 - Use data that is external to SOASTA CloudTest

Method 3 is a variation on Methods 1 and 2 in which data from outside of SOASTA CloudTest is used instead of Global Properties to control the behavior.

In order for your Test Composition to retrieve data from outside of SOASTA CloudTest, you will need to make that data available through Web Service calls. Make a Target for the Web Service, and then insert one or more Messages into your Test Composition to retrieve the necessary data from the external source through Web Service calls. Ensure that the data retrieval Messages are played before the data is needed.

When the Messages that retrieve the external data are played, the retrieved values can be placed into Custom Properties. The Messages and/or Browser Actions that you wish to parameterize can then use those Custom Properties.

Alternatively, Scripts can retrieve the external values (either from the Custom Properties or directly from the Messages), and then change their behaviors based upon the values. This allows the highest degree of customization, since you can add complex custom logic to the Script to insert computed values into the Message or Browser Action, adjust custom Script validation, or take any other action that a Script can take.

Refer to the separate question "How do I dynamically or programmatically substitute a value into a Message or Browser Action before ..." for general instructions on how to write a Script that inserts values into a Message or Browser Action.

Before you play the parameterized Test Composition, you will need to change the external data through whatever external means is appropriate.

If the external data can be updated through Web Service calls, and there are a small number of sets of values that you use regularly, you could create several Test Compositions to set up each of those common sets. You would then run the "setup" Test Composition first, followed by the parameterized Test Composition. Pairs of such Test Compositions could be placed into Playlists.

 

Attachments

    Outcomes