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

Actions in Eggplant DAI

With Eggplant DAI, you create models of your systems under test (SUTs) so that Eggplant DAI can use its algorithms to generate tests on your system. Models are composed of states and actions. States are things such as individual screens in an interface. Actions are things that users do in a given screen, or that move users between screens.

When you run a model, the Eggplant DAI engine chooses the path to follow, determining each action based on its algorithm and what steps are possible. To run tests against your SUTs, you link SenseTalk snippets from the Fusion Engine to your actions.

For detailed information about states, see Defining States in Eggplant DAI.

Types of Actions

There are three types of actions in Eggplant DAI:

  • Normal: These actions don't need to execute in any particular order relative to other actions. This is the most common action type.
  • Sequent: These actions must execute in a specific order relative to certain other actions.
  • Previous: These actions return the model to its previous state—that is, the state that caused the transition to the current state.

To change an action's type, select an action, then use the Type list menu in the Action Properties tab to select the desired action type. See Setting Action Properties for more information about action properties.

Linking an Action Back to the Same State

The Previous action type is the only type whose action is predefined specifically to cause a state change. The other action types perform whatever actions are defined in the attached SenseTalk snippets. Therefore, if you want an action to call a new state, the snippet code must explicitly make that happen.

The default behavior of the model is to stay within the same state. A state change occurs only when a state change is called by an action. For example, if the action called was to click a button or enter text in a field in a UI, the action would be performed, then the Eggplant DAI algorithm would choose its next action from within the same state—assuming the action itself didn't cause a state change.

In other words, no action is required (or available) to link an action back to its parent state. All actions remain within their state unless a new state is specifically requested by the attached snippet.

Create an Action

Follow these steps to add an action to a state within your model:

  1. On the Model workspace, select the state you're interested in.
  2. Create an action. Either:
    • On the toolbar, click New Action Create and Action.
    • Right-click in the selected state. From the action list, select New Action.
    • Use Ctrl+Shift+A.
      The new action appears, and the Action Properties tab is selected ready for completion.
  3. Configure the action using the guidelines in Setting Action Properties.
ノート

Actions are shown in the Model Tree tab in the left pane. Actions that are within a state appear in the hierarchy underneath that state, and global actions (described below) appear at the same level in the tree as states. You can move actions between parent states by dragging and dropping them on the tree view.

Global Actions

Global actions are actions that can execute in any state. A good example of a global action is screen rotation: A user can rotate a mobile device at any time while using your application, so you don't want to limit its execution to any one state.

To add a global action to your model, follow the instructions shown in Create an Action. However, instead of selecting a state (step 1), make sure that no state or action is selected. When you create an action with nothing selected, the action is a global action.

Setting Action Properties

After creating a new action, you can configure the action properties to customize its behavior. Edit these properties in the Action Properties tab, located in the right pane of the Model workspace.

General Properties Section

In the top section of the Action Properties tab, you can adjust the general properties of a action:

  • Name: A new action gets created with a default name. Change the name here to something more descriptive for your model. You can use all Unicode (UTF-8) characters, except the following: ; ! - : * = > < ^ $ , [ ] >.
  • Description: This field is optional, but you can use it to record any useful information about this action.
  • Type: Use this list to set the action type. New actions are created with the type Normal, which is typically what you will use for most actions. However, you can switch to Sequent or Previous here if required. See the Types of Actions section above for a description of each action type.
  • SUT last modified: Use this list to set the last modified date for the SUT. When calculating which action to execute next, Eggplant DAI will consider only coverage obtained after the SUT last modified date.
  • Weight: This setting lets you change the probability of an action being executed when the model runs. The default weight for an action is 100. If you change that value to 50, the action is half as likely to be executed as an action with the weight value of 100.
  • Action limit: This value sets an upper boundary for the number of times an action can be performed during a test run. Use this setting along with the Reset action limit checkbox to manage the number of times an action can run during a visit to a state or during the whole test run.
ノート

New actions have the default action limit value of 0 (zero). This value means there is no limit on the number of times the action can be visited.

  • Action time limit: This value sets an upper limit for the amount of time (in seconds) it takes for an action to execute. This setting is useful for performance testing. The default value is 0.
  • Reset action limit: This checkbox determines whether the Action limit setting applies to single visits within a state or to the entire test run:
    • When selected, Eggplant DAI resets the action's test count each time it exits a state so that the limit applies to the number of times this action can execute per visit to the state.
    • When cleared, Eggplant DAI counts the action's occurrence across the test run. In this case, the Action limit determines the number of times this action can execute during the whole test run.

Connections from Action Section

Use this section to configure an action to connect to a state. The left side of this table is for Connection Selection, and it includes three columns:

  • State: This column lists all the states in the model.

  • Connection The red arrow for the Connections column in Action Properties in Eggplant AI: Use this checkbox to create a connection between the state and the action selected in the model.

  • Visibility The eye icon for the Visibility column in Action Properties in Eggplant AI: Select this checkbox for a connection if you don't want the arrow to appear on the model. If your model is complex, with many connected actions and states, using this option can simplify your view. With this selection, the connected state is shown as a shadow box under the originating action:

    An action connected to a state shown as a shadow box rather than a connecting arrow

    In the example above, the SelectTask action connects to the TaskDetail state.

The Condition for Connection section on right side of the table is where you can set conditions that must be met before an action can connect to a state. This section includes three columns:

  • Parameter: Select a parameter from the list to set a condition.
  • Condition: Select the comparison method (i.e. <, >, ==) from the list menu that the parameter must meet before the action connects to a state.
  • Value: Set the value to evaluate against the parameter.

Snippets Called by Action Section

This section lists any snippets that you have linked to the selected action. A snippet is a specific piece of SenseTalk code that executes when this action is encountered during a test run.

Adding a snippet to connect to an action The Snippets called by action section of the Action Properties tab

You can add snippets to states or actions by using the Model workspace and Snippets tab. For information about linking snippets this way, see Linking Models to Snippets.

If you know the path of a snippet you want to attach to an action, you can add it here. Click in the Name field, then enter the snippet name.

Passing Data from Eggplant Snippets to DAI

If you want to use data resulting from the execution of a snippet in your model, specify parameters to handle the data in the Outputs field next to the snippet. Specify one parameter for each return value. If the snippet returns multiple values, specify a comma-separated list of parameters to handle all the return values.

For example, consider a snippet that generates a purchase order and contains the following handler code to return the number, state, and active status of the newly generated order:

to generate_po
return [600,"New","true"]
end generate_po

You could specify param0,param1,param2 in the Outputs field for assignment to the return values and then use that data in your model.

ノート

If the number of values returned and the number of parameters specified in the Outputs field differ, DAI will report an error when the model runs.

Action Parameters Section

Action parameters capture and provide values for states and actions. To add a parameter to an action, right-click the action, then select New Parameter in the list menu. You can also select an action, then click New in Action Parameters, located in the right pane.

Using action parameters The Action Parameters section of the Action Properties tab

To set the properties for generating a parameter, right-click the parameter, select Edit Parameter details in the context menu, then use the Parameter properties dialog box to set the criteria.

Parameter properties dialog box

  • Name the parameter. You can use all Unicode characters but double quotes in this field.

  • Select a parameter Type:

    • Integer: This selection defines a parameter as a whole number (not a fraction) that can be positive, negative, or zero. Use the integer parameter type in models when, for instance, a count of something is important, such as the number of users or test cases.

    • True or False: Use this type when your model requires a Boolean value, such as on or off, true or false, or similar values.

    • Real: The real data type accepts positive and negative whole numbers and decimals. Use a real data type for values such as for degrees, radians, or other similar information.

    • Text: Use this data type to store a string. You can also use the Text data type to define an allowable list of characters as a string. You can use all Unicode characters but double quotes in this field.

    • Set: This selection lets you define a set of allowed values for this parameter. Use this selection if you want Eggplant DAI to select a value from a specific list of values at runtime. For example: 'spring', 'summer', 'autumn', 'winter’. To input your list of values, right-click the parameter, select Edit Parameter Details from the context menu, then use the Values section of the Parameter Properties dialog box to set the values. You can use all Unicode characters but double quotes in this field.

    • Record: This selection lets Eggplant DAI read parameter values from records contained in a CSV file. Go to File > Manage Execution Environments to identify the directory containing the CSV files. When Eggplant DAI accesses this parameter, it selects one of the records from the CSV file and stores it in the parameter.

      ノート

      When using data from a CSV file to pass values to a parameter, if a row of the CSV file contains four comma separated values (e.g., "spring, summer, autumn, winter"), then the whole row will be passed to the parameter. If you only require a specific value from the list, e.g., "autumn", then you must parse it using a snippet in Eggplant Functional.

  • Set the Initial value of the parameter. When using parameters of the type Record, the option you select in Initial value will determine the .csv file from where the records should be read from.

  • Set the Generation method you want Eggplant DAI to use:

    • Generated: Generates a new value for a parameter based on its parameter type.
    • Generated Unique: Generates a value, but can't reuse a value that has been previously used.
    • Generated one-time: The generated value is selected once and then not selected again. The value remains static throughout the run.
    • Non-generated: The value is not generated and must be set to contain a value.
  • You can add Value groups to further define the parameters Eggplant DAI generates. Enter a value group as a value definition, using one definition per line.

    • Values: Enter the allowable values for this group entry. You can define parameter values as follows:

      • Enter a static value, such as 100.
      • Enter a range, such as 0:100.
      • Enter a list, such as 0, 2, 4, 6, 8.
    • Weight: Enter the relative weight you want Eggplant DAI to use when generating this parameter. For example, if you want Eggplant DAI to use this value group 50 percent of the time (as compared to the other value groups) when generating this parameter, enter 50 in this field.

    • Distribution: Select the statistical distribution method you want Eggplant DAI to use when generating this parameter:

      • Flat: Use a flat statistical distribution model.
      • Normal: Use a normal statistical distribution model.
      • Edge: Use statistical outliers.
    • Cov grps: Determines the number of segments Eggplant DAI uses to divide the values entries. Eggplant DAI begins with a value of 10 equal segments by default, then processes the values you enter for a value group and suggests a coverage group. For example, if you enter 0:360, as a value, Eggplant DAI might suggest 10 coverage groups that include 36 possible values for each coverage group to cover the value range from 0 to 360. You can manually enter a coverage group value that meets the needs for your model.

Associated Tags Section

Tags identify specific properties about a model. You can create and apply these tags to actions to track those properties within that model.

Associate tags with actions The Associated Tags section of the Action Properties tab

Use the settings in this section to associate tags with the actions in your model. See Using Tags in Eggplant DAI for information about creating tags, then applying the tags you create to an action within a model.

Preconditions for This Action to Execute Section

You might want a model execution to call an action only after a specific condition has been met. For example, a button might be disabled until data is entered in a field. To model this case, you would create actions that are enabled based on parameter values.

The Preconditions for This Action to Execute The Preconditions for This Action to Execute section of the Action Properties tab

Use this section to set evaluation criteria for preconditions. The Preconditions section lists each defined state parameter for the parent state of the selected action, along with any global parameters.

ヒント

The currentState parameter is a special predefined global parameter that contains the name of the current state. You can use this parameter to prevent a global action from being called from a specific state. For instance, if you have a global action for Quit, you might want to block that action from being called from your Initial state.

The table in this section displays the following information:

  • Scope: The state or model in which the parameter is set.
  • Parameter: The parameter name.
  • Type: The parameter type (e.g., True or False, Integer, Text).
  • Condition: An evaluation method you want to apply against the parameter value (e.g., ==, >, <). Select the appropriate method from then list to set a precondition.
  • Value: The value to evaluate a parameter against. Enter the value in this field to set a precondition.

For more information about preconditions, see Setting Preconditions for Actions.

Set and Generate Parameter Values Section

Use this section to set or generate parameter values when a given action is performed. When an Eggplant DAI model execution performs the selected action, you can change values for the parameters listed in this section. The table displays all state parameters for the parent state of the selected action as well as all global parameters.

Set and generate parameter values The Set and Generate Parameter Values section of the Action Properties tab

The table in this section displays the following information:

  • Scope: The state or model in which the parameter is set.
  • Parameter: The parameter name.
  • Type: The parameter type (e.g., True or False, Integer, Text).
  • Operation: Use this list to determine whether a parameter value is changed when the action is encountered by the model. Your choices are:
    • none: (Default) The parameter value is not changed.
    • set: Select this option if you want to set a specific value.
    • generate: Select this value if you want to generate a new value for the parameter.
  • Value: Use this list menu to select a value if you choose to set a new value in the Operation field. Your choices are determined by the type of parameter.

Checks to Perform in Action Section

Use this section to test the value of a parameter, and to display a message based on the outcome of that test when the action executes.

Checks to perform in action The Checks to Perform in Action section of the Action Properties tab

First select an action. Then you can set up the checks:

  1. Choose the Parameter for which you want to test a condition.
  2. In the Condition column, select a evaluation condition (e.g. <, >) that you want Eggplant DAI to use to test the parameter's value.
  3. Set a Value against which you want the parameter value evaluated.
  4. Enter the Message you want Eggplant DAI to display if the condition is met.

It's possible to build more complex tests using parameters. For example, you might add parameters to an action that capture responses from your SenseTalk snippets, then use these responses to create additional parameters and pass them to other snippets or actions.

Actions and Performance Testing

Setting an Action time limit in the Action Properties tab makes it possible to track the performance of your SUT. When you run a test, execution times for these actions are written to the logs.

Log Messages for an Execution Time Example of an Execution Time Message

An error is displayed when the execution time for an action exceeds the time limit that you've set.

Log messages are displayed in the Logs tab when you:

  • View the details for a test result in Controller > Test Results.
  • Run a test from Designer > Live Run.