Page MenuHomePhabricator

Phester: Add support for variables
Closed, InvalidPublic

Description

Variables are parts of yaml structure (primitive values, objects, or lists) that can be accessed by name. The name is relative to a context. For now, we assume one context per test. This is to be refined later in T227887: Phester: bind variables to session context.

Variables provide a mechanism for taking a value from a response and using it in a subsequent request. Variables may also provideaccess to configuration settings, see T228865: Phester: allow configuration to be loaded from a file.
Variables can be assigned a value in two ways:

  • directly, in a variables stanza. The variable stanza is an object mapping keys (variable names) to values. Special tags are evaluated before assigning the value, e.g. p/uniq (see T228884).
  • by "grabbing" a value in a response, using the p/grab tag followed by the variable name.

Variable values can be used as follows:

  • raw, via the p/var tag followed by the variable name.
  • (future) in an interpolation expression (ix), using the p/ix tag followed by a string. Eventually, that string should support a way to access variables (string interpolation). The specification and implementation of interpolation expressions is tracked in T228874.

Variable names follow the pattern /^[a-z][-_a-z0-9]*$/i. The characters /, \\, @, $, :, and . are reserved for use in variable expressions, e.g. as prefix separators or markers.

Example:

tests:
  - description: create and delete
     variables:
       - title: p/uniq: "Test_"    # Interpolation expression with function call
     interaction:
     -  request:                                           
           action: create
           page: p/var: title                  # defined above
     - response:
         body:
           create:
             page-id: p/grab: page-id          # grab the value from the response
     - request:
           use-session: Bob
           action: delete
           page-id: p/var: page-id             # use the value grabbed above

Event Timeline

daniel renamed this task from Add support for variables to Phester: Add support for variables.Apr 16 2019, 2:58 PM
daniel updated the task description. (Show Details)Jul 12 2019, 2:37 PM
daniel updated the task description. (Show Details)Jul 24 2019, 1:30 PM
Restricted Application added a subscriber: Liuxinyu970226. · View Herald TranscriptJul 24 2019, 1:30 PM
daniel updated the task description. (Show Details)Jul 24 2019, 3:15 PM
daniel updated the task description. (Show Details)
CCicalese_WMF closed this task as Invalid.Aug 12 2019, 6:35 PM
CCicalese_WMF added a subscriber: CCicalese_WMF.

We will not be building Phester.

Restricted Application removed a subscriber: Liuxinyu970226. · View Herald TranscriptAug 12 2019, 6:35 PM