Tables

Tables are useful for testing data variability.

Let's see the example.

Request condition: path.userId

Response variable: table.userName

Response variable: table.age

1

Foo

35

2

Bar

100

3

Baz

3

Create manifest with following rule.

type: Stub
rules:
  - request:
      path: /users/{userId}
      method: GET
    response:
      headers:
        content-type: application/json
      body:
        id: ${path.userId}
        name: ${table.userName}
        age: ${table.age}
      tables:
      - name: userName
        key: path.userId
        values:
          1: Foo
          2: Bar
          3: Baz
      - name: age
        key: path.userId
        values:
          1: 35
          2: 100
          3: 3

The stub will return the following response on the request GET /users/1:

{
  "id": 1,
  "name": "Foo",
  "age": 35
}

And on the request GET /users/2:

{
  "id": 2,
  "name": "Bar",
  "age": 100
}

Last updated