メインコンテンツまでスキップ
バージョン: DAI 26.1

Managing and Overriding Model Parameters

Parameters are placeholders (or variables) that you can use in DAI to store values for your models to use. Below you will find information about adding, editing, removing, and using parameters in DAI models.

ヒント

We recommend reading Overview of Using Parameters in DAI Models to be sure you understand the scope of the different model parameters, as well as how and where to use them before you begin working with them as described below.

Add a Parameter in the Model Editor

Instructions for adding a model parameter follow. You can find detailed explanations of the different model parameter settings on the Model Parameter Settings page.

Follow the steps below to add a new Model parameter:

  1. Open the model that you want to add the parameter to in the Model Editor. (Go to Models, select the model you want, and click Edit to open the model. Or, got to Models and click +New model to create a new model and open it.) The model opens in the workspace.

    A DAI model open in the Model Editor with the selected action highlighted in orange and its properties tab in focus on the right

    A DAI model open in the Model Editor with the selected action highlighted in orange and its properties tab in focus on the right

  2. In the model workspace, add the type of parameter you want as follows:

    • For State or Action parameters, select the state or action. DAI highlights the selected state or action in orange in the workspace and displays the State or Action Properties tab, which includes the State or Action Parameters section, on the right side of the workspace.

    • For Global Parameters, if you just opened the model, the Global Properties tab should be showing. If it is not, click anywhere in the Model workspace canvas without selecting a state or action to display the Global Properties tab on the right.

  3. Add a new parameter using either of the following methods:

    • Click New in the Global, State or Action Parameters section of the Global, State or Actions Properties tab.

    • Right-click the selected state or action, or on the canvas for global parameters, and then select New Parameter from the context menu to add a new action parameter.

      Right-click a state, action or the canvas for global parameters, to display the context menu with the **New Parameter** option

      Right-click a state, action or the canvas for global parameters, to display the context menu with the New Parameter option

      The new parameter will be added under the list of Global, State, or Action parameters where you added it.

  4. Specify the attributes for your new parameter. You can see detailed explanations of all the parameter settings in Model Parameter Settings.

    An example state parameter with **Name: Balance**, **Type: Integer**, **Initial Value: 100**, and **Generation: Non-generated**; Non-generated means you can only change the value here on the **State Properties** tab in the Model Editor or in a snippet

    An example state parameter with Name: Balance, Type: Integer, Initial Value: 100, and Generation: Non-generated; Non-generated means you can only change the value here on the State Properties tab in the Model Editor or in a snippet

    
An example action parameter with **Name: browser**, **Type: Set**, **Initial Value:** left empty, and **Generation: Generated**; Generated means DAI generates the value at runtime, and you can later override it in a test case, test config or snippet (If you set an Initial Value for a generated parameter, DAI ignores it)

    An example action parameter with Name: browser, Type: Set, Initial Value: left empty, and Generation: Generated; Generated means DAI generates the value at runtime, and you can later override it in a test case, test config or snippet (If you set an Initial Value for a generated parameter, DAI ignores it)

    • Name: Enter an appropriate name for your parameter. You can use all Unicode characters except double quotes (") in this field.

    • Type: Select the appropriate parameter type from the list menu: Integer, True or False (or similar Boolean values), Real, Text, Set (a list of allowed values), or Record (a CSV file from which to select a value). You can find detailed explanations of all these Type settings in Type Parameter Settings. Note that you may need to fine tune some settings that are only available the Parameter properties dialog box. See Edit a Parameter in the Model Editor for more information.

    • Generation: Specify one of the "Generated" options and leave the Initial Value empty to have DAI to generate the value for this parameter. Generated options also enable you to override the value in a snippet, test case or test config. DAI can generate values based on the parameter Type selected above. Specify the "Non-generated" option and a value in the Initial Value field to use this fixed value. You can only change Non-generated parameter values here in the Model Editor or in a snippet.

      ノート

      You can think of the generated options (Generated, Generated Unique, Generated one-time) as dynamic, changeable values that can be generated at runtime, or overridden later in a snippet, test case, or test config. Think of Non-generated values as static or fixed values, that you can only set and change in the Model Editor, or in a snippet. See Generation Parameter Setting Options for a detailed explanation of the different options.

    • Initial Value: Set an initial value for non-generated Set, Integer, and Record type parameters only. For parameters of type Record, the option you select in the Initial Value field will determine the CSV file from where the records should be read.

      ノート

      Some parameter settings can only be configured on the Parameter Properties dialog box, which you can display by right-clicking parameter. For more information, see Edit a Parameter in the Model Editor for information about this dialog box.

  5. When you finish entering information about your parameter, click somewhere outside the Global, State Properties, or Properties tab to save the new parameter setting. Once its added, you can see your new parameter listed under the Global, State, or Actions Propeties tab and also on the All Model Parameters tab.

Edit a Parameter in the Model Editor

To edit an existing parameter in the Model Editor:

  1. Open the model that contains the model you want to edit in the Model Editor. (Go to Models, select the model you want, and click Edit to open the model.) The model opens in the workspace.

    A DAI model open in the Model Editor with the selected action highlighted in orange and its properties tab in focus on the right

    A DAI model open in the Model Editor with the selected action highlighted in orange and its properties tab in focus on the right

  2. Display the Global, State, or Action Properties tab depending on the type of parameter you want to edit. Remember to select an action or state to see its parameters, or to be sure no actions or states are selected to see the global parameters.

  3. Locate the Global, State, or Action Parameters section on the tab, select the parameter you want, and update its information. You can read brief descriptions of the parameter settings in Add a Parameter in the Model Editor or detailed explanations in Model Parameter Settings.

To further customize parameters, right-click the parameter, then select Edit Parameter Details from the context menu. The Parameter Properties dialog box also lets you set an initial value as well as value ranges and other details, including Value groups. For detailed information about parameters, see Model Parameter Settings.

The **Parameter properties** dialog box

The Parameter properties dialog box

Remove a Model Parameter

To remove a parameter:

  1. Open the model that contains the parameter you want to remove in the Model Editor. (Go to Models, select the model you want, and click Edit to open the model.) The model opens in the workspace.

  2. Display the Global Properties, State Properties, or Action Properties tab depending on the type of parameter you want to remove, right-click the parameter in the Parameters section, then select Remove Parameter from the context menu. Remember to select an action or state to see its parameters, or to be sure no actions or states are selected to see the global parameters.

Pass Model Parameters to Snippets

You can pass any of the state, action, or global parameters that you set in a model to the SenseTalk scripts or handlers (snippets) that you link to the model. When a test of that model runs and uses the snippet, DAI passes the values (either generated or fixed) for the parameters from the model to the snippet. Note that model parameters differ in scope. See Understand the Different Types of DAI Model Parameters and their Scope for information about how to use parameters in models.

To pass parameters values from the model into your snippet, you need to define the parameters in a params statement at the top of your snippet. The following example snippet defines two parameters named account and balance, which can receive the values passed from two parameters defined in the model:

params account, balance

log "The name of the account is: " && account
log "The balance is: " && balance
ヒント

The names of the parameters you set in your DAI model do not have to match the names of the parameters you pass them to in your snippets. However, matching names can make it easier to trace the variables and their values throughout your DAI tests.

Override Parameters in Tests

To give you greater flexibility and opportunities for code reuse in your tests, DAI enables you to override the model parameter values inherited from the model in your snippets, test cases, and test configs. You can change any parameter value in a linked snippet, and you can change the values of the parameters you see in test cases and test configs.

ノート

Only the model parameters configured to be "generated" (changeable) are available in test cases and test configs, where you can override them. Specifically, this means parameters configured in the Model Editor with any Generation type, except Non-generated. See Generation Parameter Settings for more information.

Information about how to override parameters in snippets, test cases, and test configs follows.

Changing Parameter Values in a Snippet

Snippets are SenseTalk scripts or handlers linked to actions or states in DAI models. You can override the values of any model parameters that are passed into linked snippets by resetting them with a SenseTalk command within the snippet.

For example, if you have a parameter in your snippet named balance (as shown in the sample snippet below), and you pass the value for that parameter from the model to your snippet, you could override the value from the model in your snippet with the command put $200 into balance.

If you want to then use the new value in DAI, you need to configure the relevant output parameters in the model to receive the values back from the snippet. This also requires adding a return command in the snippet (which is also shown in the sample snippet below):

params account, balance -- Where the values for these parameters are passed from the model

log "The name of the account is: " && account

log "The balance is: " && balance

--Override the balance value passed from the model with the value $200
put $200 into balance

--Return the new balance value to DAI for use in tests
return balance

Note that if you override multiple parameters in a snippet, you can return them to DAI in a list formatted like this:

return [param1, param2, ...]

Changing Parameter Values in a Test Case

You can override the values of the model parameters you see in your test cases. See Define Your Model-Based Test Case and Edit an Existing Test Case for instructions.

Changing Parameter Values in a Test Config

You can override the values of the model parameters you see in your test configurations (test configs). For information about using parameters in model-based test configs, including how to override them with custom values, see Using Parameters in Model Based Test Configs.