Assign

Use Case

  • Set initial values for aliases in a request

  • Allows customization of a request beyond its initial recorded state

Think of aliases as template variables within a request which are resolved before a request is replayed. For example, let's say we use the following option:

--assign ":userId=1"

and we are about to replay:

GET /users/1

and we have defined the endpoint as such (where :userId is an alias):

GET /users/:userId

Then the replayed request will actually be:

GET /users/1

This concept works for query params, headers and body params (for requests that have a parseable body).

CLI Examples

stoobly-agent scenario run --assign ":userId=1" <SCENARIO-KEY>
stoobly-agent scenario test --assign ":userId=1" <SCENARIO-KEY>
stoobly-agent request run --assign ":accessToken=secretToken" <REQUEST-KEY>
stoobly-agent request test --assign ":accessToken=secretToken" --assign ":userId=1" <REQUEST-KEY>

Configuring Resolve Strategy

Now let's say we assign two values to the alias :userId, for example:

stoobly-agent scenario run --assign ":userId=1" --assign ":userId=2" <SCENARIO-KEY>

In this case, how do we determine which value gets resolved first?

Last updated