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

Linking Eggplant DAI Models to Snippets

Eggplant DAI models of systems under test (SUTs) are built out of specific states and actions that take place within those states. SenseTalk code snippets from Eggplant Functional integrate with Eggplant DAI to interact with SUTs. Snippets are connected to specific actions or states in your model. You can create snippets quickly in Eggplant Functional using Autosnippet generation.

What Are Snippets in Eggplant DAI?

A snippet can be as simple as a single line of SenseTalk code that clicks a button in the UI, or it can be multiple lines of code that perform more complex actions, like reading a username or password from an external data file, then entering that information for a specific action step in a model. These pieces of code can be Eggplant Functional handlers.

As you build models, it’s useful to think about each action as a small, discrete activity that a user would perform while interacting with the application or software that you're testing. Following that method, you should be able to write simple SenseTalk snippets to perform those actions.

You can also look for actions that are the same, or very similar, in different states or areas of the model, so you can reuse the same code snippet to serve multiple purposes. SenseTalk is highly flexible and lends itself to this modularized approach to scripting.

You can find complete information about writing SenseTalk code in Eggplant Functional here:

Using Snippets

In Designer > Models, your SenseTalk snippets appear in the Snippets tab in the left pane. Note that, for a model, you specify the Suite relative location in the Snippets tab, in addition to specifying the Eggplant Functional suite location in the Manage Execution Environments window.

ノート

If your scripts are located in c:\users\DAIuser\suite_location.suite root folder, where, c:\users\ is specified in the Manage Execution Environments window, then, DAIuser\suite_location.suite will be the relative path for that model.

See Connecting an Eggplant Functional Suite for complete instructions.

Additionally, your suite connection identifies a specific agent connection, and that agent must be running for your snippets to be available on the Snippets tab. See Configuring the Eggplant DAI Execution Environment for complete instructions. When the agent is running and the model has a suite defined, the Snippets tab shows a green light indicator:

The Snippets tab in  Eggplant DAI with a connected Eggplant Functional suite

The Snippets tab displays all the scripts in the attached Eggplant Functional suite so that you can connect those scripts to actions in the model. You might want to create suites for specific applications or models that you are building within Eggplant DAI; those suites should hold the snippets only for those models.

Within Eggplant DAI, you can view the code for any snippet that appears in the Snippets tab. Right-click the snippet in the pane, then select View Snippet. The SenseTalk code opens in a new tab in the Console area at the bottom of the Modeler window. You can have multiple snippets open at once, and you can close the tabs individually. Right-click in the Snippets pane, then select Clear Viewed Snippets to close all open snippet tabs in the Console.

ヒント

You can also edit your snippets using the Script Editor in the Designer > Snippets tab. For more information, see the Designer page.

To configure snippets to run tests on a SUT as your model runs, associate SenseTalk snippets with Eggplant DAI states or actions:

  1. Select a state or action in the Model tab.
  2. In the Snippets tab in the left pane, right-click the script you want to add to the selection.
  3. Select Add to Selected from the context menu to add the chosen script to the state or action.

If necessary, you can connect multiple snippets to a single state or action.

Each action in the workspace has two dots in the upper-left corner. The left dot turns green when a snippet is attached. The right dot indicates if a submodel is attached. If you hover your cursor over a green dot, a tooltip shows what snippet or submodel is attached.

An Eggplant AI action with an attached submodel shows a green dot on the right

You can connect both snippets and submodels to the same action. When both snippets and submodels are attached to an action, snippets run first, followed by submodels.

Using the Properties Tab

You can use the Properties tab in the right sidebar to set or change properties for attached snippets. Select a state or action in the model workspace. Depending on your selection, the Action Properties or State Properties tab appears in the right sidebar. Note the following:

  • If you're looking at action or state properties, the Snippets called by section lists any snippets connected to the selected action or state. Select Disabled for any snippet that you don't want this model to execute.
  • In the Name field of the Snippets called by section, you can enter the name of a snippet that you want to connect to the selected action or state.

You can modify the properties in the Snippets called by section using the Snippet Properties I/O Edit dialog box:

  1. Right-click the Snippets called by state or Snippets called by action pane.

  2. Select Edit Snippet Interface from the context menu.

    ノート

    The context menu lets you remove and view a snippet as well as opening the Snippet Properties I/O Edit pane.

    View the Snippet Properties I/O Edit dialog box The Snippet Properties I/O Edit dialog box

You can choose state or action parameters for the script to use as inputs, outputs, or both, when a run encounters that state or action. Select Input, Output, or both in the dialog box.

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

For information about model actions, see Actions in Eggplant DAI.