Generate test configurations

Relevant for: GUI tests and business process tests

This task describes how to use the Test Combinations Generator to generate test configurations, enabling you to create a larger variety of test configuration data sets. These test configurations can be used to test a wider variety of scenarios for your application.

Note: This task is part of a higher-level task. For details, see Set up and run test configurations.

Tip: For a use-case scenario related to this task, see Use-Case Scenario: Use the Test Combinations Generator.

Prerequisites

Before using the Test Combinations Generator, create data table parameters in the Global sheet (for a GUI test) or test parameters (for a business process test).

To create parameters

  • GUI tests: Double-click a column header in the Data table in the Global tab of the Data pane and enter the parameter name.

  • BPT tests: In the Parameters tab of the Properties pane, click Add and select Add Input Parameter. Then, in the grid, define the parameter details.

Back to top

Open the Test Combinations Generator

Do one of the following:

For a GUI test With a GUI test tab in focus, in the toolbar, click the Test Combinations Generator button and select the test for which you want to generate test combinations.
For a business process test In the Properties pane, select the Test Configurations tab , and then click the Test Combinations button.

Back to top

Set the value of your parameters

Enter the possible values for your parameters as follows:

Manually

Click on a cell and enter the values for the parameters as needed or cut and paste into the grid as needed.

Import

Do one of the following:

  • Click the Import button to automatically import values for the parameters. Import an Excel file from the file system or an ALM project.
  • For GUI tests only: In the Resources pane of the Test Settings dialog box (File > Settings > Resources node), select the Other location option and click the Browse button to specify a data table.

Back to top

Automatically generate values for parameters

  1. In the Parameter Values pane of the Test Combinations Generator, in the upper right hand corner, click Generate Parameters.

  2. In the Generate Parameters pane, from the Parameter drop-down list, select the Parameter to generate.

  3. From the Generation Type drop-down list, select the type of value to generate.

  4. For certain types of values, select the other options as needed. For example, for the First Name or Full Name value types, you can select English or Non-English types.

  5. Specify the number of entries to generate.

    The Test Combinations Generator only generates unique items, without duplicating values. For example, if you instruct UFT to generate 20 entries, but limit the available values to the numbers between 95 and 100, only 6 entries are generated.

  6. In the lower right corner of the pane, click Generate. The values are added the your list of parameter values used to generate test cases.

Back to top

Add a custom data generator

In addition to using UFT's built-in dictionaries, you can create a custom data generator for the parameter types in your test:

  1. Create an .xml file for your data generator.
  2. In the XML file, add the following XML:

    <Generators>
     <DataGenerator name="[CustomGeneratorName]" type="[GeneratorType]" title="[GeneratorTitle]" returnType="[GeneratorResultType]">
     ...
     </DataGenerator>
    </Generators>
    name A unique name for the generator type.
    type

    The generator type. Possible values:

    • HP.UFT.TCG.DataGeneration.Generators.RegExpGenerator: to specify the value format using a regular expression

    • HP.UFT.TCG.DataGeneration.Generators.BaseRepositoryGenerator: to specify the values with standard strings, numbers, etc.

    title The title of the Generation Type as it is displayed in the Test Configurations Generator.
    returnType

    The format of the values to return. Supported types include:

    • String

    • Password

    • Number

    • Date

    Note: You can add multiple generator types in this XML file.

  3. In the Data Generator attribute, specify the parameter details using the Parameter element:

    <Generators>
     <DataGenerator name="[CustomGeneratorName]" type="[GeneratorType]" title="[GeneratorTitle]" returnType="[GeneratorResultType]">
    	<Parameters>
    		<Parameter .... />
    	</Parameters>
     </DataGenerator>
    </Generators>

    The attribute values for the Parameter element differ if you are using the regular expression type (HP.UFT.TCG.DataGeneration.Generators.RegExpGenerator) or the regular tyle (HP.UFT.TCG.DataGeneration.Generators.BaseRepositoryGenerator):

    Regular expression
    • name: must be the string pattern

    • defaultValue: the default regular expression pattern

    • type: must be the string System.String

    Non-regular expression
    • name: a unique name for the parameter

    • defaultValue: the default parameter value

    • type: must be the string System.Boolean

    • title: the parameter title

  4. For non-regular expression-based parameter types, add the Repositories element:

    <Generators>
     <DataGenerator name="[CustomGeneratorName]" type="[GeneratorType]" title="[GeneratorTitle]" returnType="[GeneratorResultType]">
    	<Parameters>
    		<Parameter .... />
    		</Parameter>
    	</Parameters>
    	<Repositories>
    		<Repository.... />
    		</Repository>
    	</Repositories>
     </DataGenerator>
    </Generators>

    The Repository element must contain the following attributes:

    name A unique name for the repository.
    path The path to the Excel file containing the possible values.
    useWhenCheck

    The name of the parameter entered in the Parameter element. This instructs UFT to use the repository when a checkbox for one of the parameter values is checked.

    rule The format for data generation.
  5. Add the XML file to the <UFT installation folder>/dat/DataGenerators folder.

Set values as Happy Path or Error Path

Select a component value and click one of the following:

Happy path The value is expected not to cause an exception or error.
Error path The value is expected to cause an exception or error. This is useful for negative testing of your application.

UFT changes the selected parameter to green (for Happy Path values) or red (for Error Path values).

Back to top

Create composite parameters

  1. In the Parameter Values tab, select the columns for which you want to create a composite parameter by clicking the column header.

  2. Right-click the selected columns and select Join.

    The columns are colored gray to show the locked status.

    Note: If the provided possible values are not equal between the selected parameters, UFT fills in the missing partner value with an empty string. For example, if ParamA with 8 values is combined with ParamB with 5 values, the additional combinations lacking from ParamB are filled in with empty strings.

    When UFT generates the combinations, these parameters are combined together.

Back to top

View the selected parameter combinations

After entering the possible values for all parameters, click View Combinations.

UFT displays all the possible combinations for your parameter values as follows:

Regular/Happy path values All possible combinations of the values are listed in the Permutations tab.
Error path values All possible combinations are listed in the Error Paths tab, using the error path values.

Back to top

Change the testing combination algorithm

UFT can generate different configurations depending on the selected combination algorithm (Linear, Pairwise, or Triplewise):

In the Permutations tab, from the Algorithm drop-down list, select the appropriate algorithm for your testing needs. UFT updates the list of permutations accordingly.

Note: Depending on the number of parameters, possible values, and combination algorithm, you may generate a large number of possible configurations.

Back to top

Select the configurations to generate

If you define values as Happy Path or Error Path, you also have the option to generate all the different parts of the configuration.

  1. In the Permutations tab, click the Filter button.

  2. In the filter, select the combinations to generate.

  3. If necessary, enter a name for the generated configuration.

Back to top

Generate the test configurations

For BPT tests

In the bottom of the Test Combinations Generator, click Generate.

UFT pauses for a few seconds or more (depending on the number of combinations), and creates the test configuration. The new configuration is then added in the Test Configurations tab of the Properties pane (for business process tests).

If you specified Happy path or Error path values and instructed UFT to generate these combinations, additional parameters are created, named Is_Happy and Is_Error. In additional relevant columns are added to the data resource file.

Note: To exclude a column from being included in the configuration generation, in the Parameter Values tab, right-click the columns to exclude and select Exclude.

When columns are excluded, the default parameter value is used in the configuration generation.

This configuration is saved with the test and is available to use in test runs.

For GUI tests

In the bottom of the Test Combinations Generator, click Generate.

UFT pauses for a few seconds or more (depending on the number of combinations), and creates the test configuration. The new configuration is then added in the Global tab of the Data pane.

Note: To exclude a column from being included in the configuration generation, in the Parameter Values tab, right-click the columns to exclude and select Exclude.

When columns are excluded, the default parameter value is used in the configuration generation.

If you specified Happy path or Error path values and instructed UFT to generate these combinations, separate sheets are added to the /Configurations directory with a _Happy and _Error suffix to name and displayed in the Test Configurations dropdown list in the toolbar.

In the Global table, the Error path values are not placed in a separate sheet.

This configuration is saved with the test and is available to use in test runs.

Note: The generated configuration is saved in the test folder, in the /Configurations directory, but not automatically saved to ALM (if your test is saved in ALM). If your test is saved in ALM, the configurations are not displayed in Test Configurations dropdown list in the toolbar. Instead, you can find your configurations if you browse the /Configurations directory.

Add your test data to your ALM Test Resources

This section is relevant only when working with GUI tests.

After the configurations are generated, you can upload them from the /Configurations directory to the ALM Test Resources module.

For details, see Create a data resource file.

Add your test data to your ALM test

This section is relevant only when working with GUI tests.

  1. In ALM's Testing module, select Test Plan.

  2. Browse to and open your test, or create a new test configuration. Click the ID link to open the Test Configuration Details dialog box.

  3. In the Test Configuration Details dialog box, select Data on the left, then select Override test data resource.

  4. From the Data Resource drop-down, select the data table resource you uploaded earlier.

  5. In UFT, reopen the test, and set the data table to the data table resource now saved in ALM.

    1. Open the Test Settings Resources pane (File > Settings > Resources).

    2. In the Data Table area, select Other location, and browse to and select your data table.

The data source is added to the Data Table area of the Resources pane.

Back to top