Skip to content

Parameterization

AngusTester provides the following 4 parameterization methods to meet different testing needs:

  • Variables: Define constant values that can be shared throughout the test
  • Datasets: Define a set of related parameters with dynamically changing values during testing
  • Mock Functions: Dynamically generate parameter values or random values
  • Sampling Extraction Variables: Extract values from previous sampling results for subsequent use

Variables

Define single reusable values referenced using {variable_name} format. Supports:

  1. Static values
  2. Values generated by Mock functions
  3. Values extracted from HTTP/files/databases

📌 Important: Variable values are fixed before sampling execution and do not change during execution

Field NameTypeRequiredLength LimitDescription
namestringYes<=100Variable name
descriptionstringNo<=200Variable description
valuestringNo*<=4096Variable value (required for non-extracted variables), supports Mock functions like @String(5,10)
passwordValuebooleanNo/Whether it's a password value (hidden in UI if true)
extractionobjectYes*/Extraction configuration (required for extracted variables), see Extraction Configuration below

Example: Static Variable

yaml
configuration:
  variables:
  - name: myUsername
    value: xcan

Example: Password Variable

yaml
configuration:
  variables:
  - name: myPassword
    value: 123456
    passwordValue: true

Example: Mock Function Variable

yaml
configuration:
  variables:
  - name: userId
    value: '@Uuid()'  # Generates new UUID each iteration

💡 Feature: Mock function variables remain constant within the same iteration, supporting resource CRUD testing
⚙️ Can disable iteration updates via updateVariableByIteration configuration (enabled by default)

Example: HTTP Extraction Variable

yaml
configuration:
  variables:
  - name: accessToken
    extraction: 
      source: HTTP
      method: JSON_PATH
      expression: $.data.access_token
      location: RESPONSE_BODY
      request:  # HTTP request configuration
        method: POST
        url: http://example.com/login
        body:
          rawContent: "{\n    \"username\":\"admin\",\n    \"password\":\"admin\"\n}"

Advantage: Automatically updates time-sensitive data like tokens, avoiding manual maintenance

Example: File Extraction Variable

yaml
configuration:
  variables:
  - name: hobbies
    extraction: 
      source: FILE
      fileType: CSV
      path: /data/user.csv
      rowIndex: 3  # 4th row (0-based index)
      columnIndex: 2 # 3rd column

📝 Supported file formats: CSV/Excel

Example: Database Extraction Variable

yaml
configuration:
  variables:
  - name: userCount
    extraction: 
      source: JDBC
      select: SELECT count(*) FROM users
      datasource:
        type: MYSQL
        username: sample
        password: 123456
        jdbcUrl: jdbc:mysql://host:3306/db

Datasets

Define sets of related parameters (e.g., test data) referenced using {parameter_name}. Supports:

  1. Static datasets
  2. File extraction
  3. JDBC extraction

🔄 Dynamic Feature: Parameter values change dynamically during execution

Field NameTypeRequiredLength LimitDescription
namestringYes<=100Dataset name
descriptionstringNo<=200Dataset description
parametersarray[object]No*<=200Parameter list (required for static datasets)
extractionobjectYes*/Extraction configuration (required for extracted datasets)

Parameter Configuration

Field NameTypeRequiredLength LimitDescription
namestringYes<=100Parameter name
valuestringNo*<=4096Parameter value (required for static parameters)

Example: Static Dataset

yaml
task:
  pipelines:
    - target: HTTP
      name: UpdateUserEmail              # Update user email
      request:
        method: PATCH
        url: http://example.com/api/v1/user/email
        body:
          rawContent: "{\"id\":\"{id}\",\"email\":\"{email}\"}"
      datasets:
      - name: UserData
        parameters:  # Define parameter columns
        - name: id
          value: '@Uuid()'  # Dynamically generate ID
        - name: age
          value: '@Email()' # Dynamically generate Email

Example: File Dataset

yaml
task:
  pipelines:
    - target: HTTP
      name: UpdateUserEmail              # Update user email
      request:
        method: PATCH
        url: http://example.com/api/v1/user/email
        body:
          rawContent: "{\"id\":\"{id}\",\"email\":\"{email}\"}"
      datasets:
      - name: CSVData
        parameters:  # Define parameter columns
        - name: id
        - name: email
        extraction:
          source: FILE
          fileType: CSV
          path: /data/users.csv

Example: Database Dataset

yaml
task:
  pipelines:
    - target: HTTP
      name: UpdateUserEmail              # Update user email
      request:
        method: PATCH
        url: http://example.com/api/v1/user/email
        body:
          rawContent: "{\"id\":\"{id}\",\"email\":\"{email}\"}"
      datasets:
        - name: DBData
          parameters:  # Define parameter columns
          - name: id
          - name: email
          extraction:                                 # Extraction configuration
            source: JDBC                              # Value source, fixed value: JDBC
            method: EXACT_VALUE                       # Extract values using exact value method
            datasource:                               # Datasource configuration
              type: MYSQL
              username: sample
              password: 123456
              jdbcUrl: jdbc:mysql://host:3306/db
            select: SELECT * FROM users               # SQL query for dataset values (no pagination needed, defaults to 5000 records per fetch)
            rowIndex: 0                               # Specify starting row (default 0)
            columnIndex: 0                            # Specify starting column (default 0)

Mock Functions

Generate dynamic values using @function_name() format, e.g., @Email() generates email addresses. Supports:

  • Text generation (names/addresses/IDs etc.)
  • Number generation (integers/decimals/ranges)
  • Date generation (dates/times/timestamps)

📚 See dedicated Mock Functions Documentation

Sampling Extraction Variables

Extract values from current sampling requests/responses for use in subsequent samplings

yaml
task:
  pipelines:
    - target: HTTP
      name: AddGroup               # Add group
      enabled: true
      request:
        method: POST
        url: http://example.com/api/v1/group
        body:
          rawContent: "[{\"code\":\"TestGroup\",\"name\":\"测试组\",\"remark\":\"\",\"\tagIds\":[]}]"
      variables:
        - source: HTTP_SAMPLING     # Value source, fixed value: HTTP_SAMPLING
          name: groupId             # Extract group ID from response: {"code":"S","msg":"成功","data":[{"id":"235027106575356558"}],"datetime":"2024-07-17 15:02:09","ext":{}}
          method: JSON_PATH
          expression: $.data.id
          location: RESPONSE_BODY
    - target: HTTP
      name: QueryGroup              # Query group
      enabled: true
      beforeName: ModifyGroup
      request:
        method: GET
        url: "http://example.com/api/v1/group/{id}"
        parameters:
          - name: id
            in: path
            enabled: true
            type: string
            value: "{groupId}"                      # Note: Reference sampling variable {groupId} in Path parameter

Extraction Configuration

AngusTester supports data extraction from five sources: text values, HTTP, HTTP sampling, files, and JDBC.

Common Extraction Parameters

ParameterTypeRequiredLimitDescription
namestringConditional≤100 charsExtraction identifier.
Note: For sampling extraction variables, this serves as the variable name and is mandatory.
methodenumYes-Extraction method: EXACT_VALUE,REGEX,
JSON_PATH,X_PATH
expressionstringConditional≤1024 charsExtraction expression (required for non-exact value methods)
matchItemintegerNo0-1024Index position for multi-value matching
defaultValuestringYes≤4096 charsDefault value when extraction fails
sourceenumYes-Data source identifier: VALUE,FILE,HTTP,
HTTP_SAMPLING,JDBC

Text Value Extraction (source=VALUE)

Extraction Note

Text value extraction directly extracts data from given text content.

Field NameTypeRequiredLength LimitDescription
sourceenumYes/Extraction source, fixed value: VALUE.
See "Matching Source (source)" for details.

Extraction Methods (method)

MethodDescriptionUse Cases
EXACT_VALUEExact value extraction
Gets raw content directly without expression matching
- Full content extraction
- Unformatted data processing
REGEXRegular expression extraction
Matches target data using regex patterns
- Text pattern matching
- Unstructured data processing
JSON_PATHJSON path extraction
Uses JSONPath syntax to locate data in JSON structures
- JSON response parsing
- API data extraction
X_PATHXML path extraction
Uses XPath syntax to locate data in XML documents
- XML file parsing
- SOAP interface testing

Match Item (matchItem)

When expressions match multiple values or results are arrays, specifies which value to use as the expected result (0-based index up to 2000). Returns null if specified position doesn't exist. Merges multiple values when not specified.

  • Regex matching

    • Match value:
      txt
      hello, RegexExtraction! my phone number is 18888888888 and 13999999999.
    • Expression: (1\d{10})
    • Match result: ["18888888888","13999999999"]
    • Match item:
      • Default (no position): Merged result "1888888888813999999999"
      • Position 0: "18888888888"
      • Position 1: "13999999999"
  • JSONPath matching

    • Match value:
      json
      {
        "store": {
          "book": [
            {"title": "Sayings of the Century", "price": 100},
            {"title": "Confucianism", "price": 200}
          ]
        }
      }
    • Expression: $.store.book[*]
    • Match result: [{"title":"Sayings...","price":100},{"title":"confucianism","price":200}]
    • Match item:
      • Default: Full array
      • Position 0: {"title":"Sayings...","price":100}
      • Position 1: {"title":"confucianism","price":200}
  • XPath matching

    • Match value:
      xml
      <persons>
        <person><age>30</age><interests>coding</interests><interests>basketball</interests><name>Angus1</name></person>
        <person><age>32</age><interests>coding</interests><name>Angus2</name></person>
      </persons>
    • Expression: /persons/person[age >= 30]
    • Match result: "30codingbasketballAngus1", "32codingAngus2"
    • Match item:
      • Default: Merged "30codingbasketballAngus132codingAngus2"
      • Position 0: "30codingbasketballAngus1"
      • Position 1: "32codingAngus2"

Matching Sources (source)

SourceDescriptionUse Cases
VALUEExtract directly from text content- Fixed text parsing
- Expression validation
- Simple data extraction
FILEExtract from local/remote files- Batch data processing
- Test dataset loading
- File format conversion
HTTPGet data via API requests- Preloading dynamic data
- Authentication tokens
- Cross-system integration
HTTP_SAMPLINGReal-time extraction from test API responses- Chained API calls
- Dynamic parameter passing
- Contextual testing
JDBCExtract from database queries- Business data validation
- Database status checks
- Data-driven testing

File Extraction (source=FILE)

Extraction Note

File extraction reads structured data from local/remote files (CSV/Excel). Note: Both variables and datasets support this method.

Field NameTypeRequiredLength LimitDescription
sourceenumYes/Extraction source, fixed value: FILE.
fileTypeenumYes/File type, supports CSV and EXCEL, defaults to CSV.
encodingstring/File encoding
quoteCharobjectNo/CSV quote character (default "") for fields containing special characters
escapeCharobjectNo/CSV escape character (default "") for escaping special characters
separatorCharobjectNo/CSV field separator (default ",")
rowIndexintegerNo/Starting row index (0-based, default 0)
columnIndexintegerNo/Starting column index (0-based, default 0)
yaml
extraction:                                 # Extraction config
  source: FILE                              # Fixed value: FILE
  name: Extract from csv file
  method: EXACT_VALUE                       # Exact value extraction
  fileType: CSV                             # CSV file
  path: /data/user.csv                      # File path
  encoding: UTF-8                           # File encoding
  quoteChar: '"'                            # Quote character
  escapeChar: \                             # Escape character
  separatorChar: ","                        # Separator
  rowIndex: 4                               # Starting row (0-based)
  columnIndex: 2                            # Starting column (0-based)

HTTP Extraction (source=HTTP)

Extraction Note

HTTP extraction extracts target data from API responses via predefined HTTP requests. Note: Variables support HTTP extraction; datasets do not.

Field NameTypeRequiredLength LimitDescription
namestringNo*/Extraction name (required as variable name for sampling extraction)
methodenumYes/Extraction method (see "Extraction Methods")
expressionstringYes*/Extraction expression (required for REGEX/JSON_PATH/X_PATH)
matchItemintegerNo/Match item index for multi-value results
defaultValuestringYes/Default value when extraction fails
sourceenumYes/Fixed value: HTTP
locationenumYes/Extraction location (see "Extraction Locations")
parameterNamestringNo/Parameter name (required for header/query/path/form extractions)
requestobjectNo/HTTP request configuration

Extraction Locations (location)

  • Request data locations
LocationDescriptionExample
PATH_PARAMETERURL path parameters/users/{user_id}
QUERY_PARAMETERURL query parameters?order_id=12345
REQUEST_HEADERHTTP request headersAuthorization: Bearer token
FORM_PARAMETERForm parametersusername=admin&password=123
REQUEST_RAW_BODYRaw request bodyJSON/XML content
  • Response data locations
LocationDescriptionExample
RESPONSE_HEADERHTTP response headersSet-Cookie: session_id=abc
RESPONSE_BODYResponse body contentAPI JSON/XML data
yaml
extraction: 
  source: HTTP                                      # Source of extraction value, fixed value: HTTP  
  name: Extract access_token value                 
  method: JSON_PATH                                 # Method to extract value: JSON_PATH  
  expression: $.data.access_token                   # JSONPath extraction expression  
  defaultValue: a4b08effa7bf4bfb9579fb2fe96e1812    # Default value returned if extraction fails or expression is invalid  
  location: RESPONSE_BODY                           # Extraction location: from response body  
  request:                                          # HTTP request configuration  
    method: POST  
    url: http://example.com/user/signin  
    body:  
      rawContent: "{\n    \"username\":\"admin\",\n    \"password\":\"admin\"\n}"

HTTP Sampling Extraction (source=HTTP_SAMPLING)

Extraction Note

HTTP Sampling Extraction dynamically retrieves data from HTTP request/response contexts during test execution.

Field NameTypeRequiredLength LimitDescription
sourceenumYes/Extraction source, fixed value: HTTP_SAMPLING.
locationenumYes/Extraction location. Refer to the "Extraction Location (location)" section below for supported conditions.
parameterNamestringNo/Parameter name for extraction. Required when extracting from request headers, response headers, query parameters, path parameters, or form parameters.
yaml
variables:  
- source: HTTP_SAMPLING     # Source of extraction value, fixed value: HTTP_SAMPLING  
  name: groupId             # Extract from the current sampling response  
  method: JSON_PATH  
  expression: $.data.id  
  location: RESPONSE_BODY

JDBC Extraction (source=JDBC)

Extraction Note

JDBC Extraction retrieves field values from database result sets via SQL queries. Note: Both variables and datasets support this method.

Field NameTypeRequiredLength LimitDescription
sourceenumYes/Extraction source, fixed value: JDBC.
datasourceobjectYes/Data source configuration. Refer to the "Data Source Configuration Parameters (storeDatasource)" section for details.
selectstringYes/SQL SELECT statement for querying table data, max 1024 characters. Note: For dataset extraction, SELECT defaults to 5000 rows per query.
rowIndexintegerNo/Starting row index for reading parameter values (0-based). Note: If the first row is a header, typically start from index 1 (second row).
columnIndexintegerNo/Starting column index for reading parameters (0-based).
yaml
extraction:                                 # Extraction configuration  
  source: JDBC                              # Source of extraction value, fixed value: JDBC  
  name: Extract value from MYSQL database  
  method: EXACT_VALUE                       # Method to extract value: EXACT_VALUE  
  datasource:                               # Data source configuration  
    type: MYSQL  
    username: sample  
    password: 123456  
    jdbcUrl: jdbc:mysql://mysql01-sample.angusmock.cloud:3306/xcan_mockdata_sample  
  select: SELECT * FROM `user`              # SQL query for dataset values (no pagination needed; defaults to 5000 rows per fetch)  
  rowIndex: 0                               # Starting row index (default: 0, first row)  
  columnIndex: 0                            # Starting column index (default: 0, first column)

Released under the GPL-3.0 License.