Skip to content

Generator Sets

Generator Sets in Aptori provide a powerful, global way to manage dynamic variables for your automated tests. By leveraging Regular Expressions for both variable names and values, Generator Sets allow you to seamlessly and automatically fill test data in any field that matches a defined pattern.

Overview

  • Global Test Data: Generator Sets are defined at the organization level, making them accessible to all users within that organization.
  • Multiple Variables: Each Generator Set can house multiple variables, allowing you to group related test data (e.g., different user attributes).
  • Automatic Matching: Variable names themselves can be regex patterns that Aptori uses to detect and replace matching fields in your API requests or forms.

By centralizing test data generation and using regular expressions for matching, Generator Sets drastically reduces the need for repetitive test data definitions in each test (Sift).

Key Features

  1. Regex-Based Variable Names
    A variable’s name can be a simple or advanced regex (e.g., phoneNumber, .*Email$), allowing Aptori to automatically detect fields that match that pattern.

  2. Multiple Types of Values
    Each variable can be one of three types:

    • String: Holds a static or templated text value.
    • Regex: Generates randomized strings based on a regex pattern.
    • Number: Produces numeric values (e.g., random within a range or a static number).
  3. Dynamic Data Generation
    For Regex variables (both names and values), Aptori will generate new data at runtime, ensuring fresh test data for each test run.

  4. Global Scope & Accessibility
    Once created by the organization owner, any user can reference or automatically apply these variables in their Sifts.

  5. Consistency & Scalability
    Changes to a variable in one place are reflected everywhere it’s used, simplifying maintenance and allowing your tests to scale more easily.

How It Works

  1. Create a Generator Set
    The organization owner creates or updates a Generator Set with one or more variables.

  2. Define the Variable Name and Value

    • Name: Can be a plain text name (e.g., phoneNumber) or a regex pattern (e.g., ^phoneNumber$ or ^phone.*).
    • Value: For String and Number generators, specify an exact value to use for the field in a request. For Regex generator, specify a pattern (e.g., \d{10} for a 10-digit number) to produce a dynamic value in each request containing a field that matches the variable name.
  3. Aptori Matches Fields Automatically

    • When a Sift executes, any input field whose key matches the variable’s name (including regex) is automatically replaced with the generator’s value.
    • If the variable is assigned a Regex generator for its value, the replaced text is a dynamically generated string adhering to that pattern.

Setup & Configuration

  1. Navigate to “Generator Sets” Access the Generator Sets section in Aptori using the left navigation.

  2. Create or Edit a Generator Set

    • Click Add + or edit an existing one.
    • Provide a name for the Generator Set (e.g., UserDetails).
  3. Add Variables
    Each variable entry includes a name, type, and value. The name is a Regex; the type can be either String, Number, or Regex. Example:

    • name (phoneNumber): The regex pattern to match input fields.
    • type (Regex): Indicates this generator uses a regex pattern to produce values.
    • value (\d{10}): The pattern for the generated 10-digit number.
  4. Save Your Generator Set
    Once saved, the variables become available across the organization.

  5. Select the Generator Sets to Use in a Configuration
    Navigate to the Configurations section in Aptori. Create a new configuration or edit an existing one. Within the configuration, go to the Optional settings and choose the Generator Sets to be used as Global Generators.

Best Practices

  1. Use Descriptive Regex Names

    • Make sure your variable names clearly indicate the field(s) they should match (e.g., ^phoneNumber$ rather than a broad pattern).
  2. Organize Variables by Function

    • Keep related variables (e.g., “User Data,” “Payment Info”) together in the same Generator Set for easier maintenance.
  3. Test Your Patterns

    • Use a regex tester to confirm you’re matching the exact fields (neither missing nor overly capturing fields).
  4. Avoid Overly Broad Names

    • Be mindful not to create a variable name like .* which would inadvertently match and replace all fields.