You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+14-4Lines changed: 14 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -159,6 +159,16 @@ A test file looks like the following:
159
159
"expected": {
160
160
"statuscode": 200
161
161
}
162
+
},
163
+
{
164
+
"name": "121007",
165
+
"server": "hackernews",
166
+
"method": "GET",
167
+
"endpoint": "/v0/item/121007.json",
168
+
"expected": {
169
+
"statuscode": 200,
170
+
"response": "\\s+[wW]eight"
171
+
}
162
172
}
163
173
]
164
174
}
@@ -186,7 +196,7 @@ A test file contains an array of tests, each of them containing:
186
196
187
197
-`statuscode` (mandatory): the expected status code returned by the endpoint (200, 401, 403, etc.)
188
198
189
-
-`response` (default none): the expected payload returned by the endpoint. This field is optional
199
+
-`response` (default none): the expected payload returned by the endpoint.
190
200
191
201
> Please note that `payload` and `response` can be either a string (including json, as shown in 121004), or `@file` (as shown in 121005) or even a `@custom_filename.json` (as shown in doesnotwork). This is useful if you prefer to separate the test from its `payload` or expected `response` (for instance, it is handy if the `payload` or `response` are complex JSON structs that you can easily copy and paste from somewhere else, or simply prefer to avoid escaping double quotes). However, keeping the names for `payload` and `response` like `test_name.payload.json`and `test_name.expected.json` is still a good practice.
192
202
@@ -209,7 +219,7 @@ As we saw earlier, for each test, you will have to define the expected response.
209
219
- if the response is a non-JSON string:
210
220
- the response is compared to `expected` and success or failure is reported
211
221
212
-
> Please note that, in the case of non-JSON responses, you can use the `%` character to match start, end or part of the response, pretty much like in SQL. For instance, expected responses like `"%test"`, `"test%"` and `"%test%"` will match test at the beginning, end or as part of the returned response respectively.
222
+
> Please note that, in the case of non-JSON responses, you can use regular expressions (see test 121007). In that case, make sure the `expected.response` field is set to a proper, compilable, regular expression. Be mindful that you will need to escape the `\ (backslash)` character using `\\`. For instance `\s+[wW]eight` will be written `\\s+[wW]eight`, in order to match one or more whitespace characters, followed by weight or Weight.
213
223
214
224
## Running okapi :giraffe:
215
225
@@ -227,9 +237,9 @@ where options are one or more of the following:
227
237
228
238
-`--file-parallel` (default no): run the test files in parallel (instead of the tests themselves)
229
239
230
-
-`--file` (default none): only run the specified test file
240
+
-`--file`, `-f` (default none): only run the specified test file
231
241
232
-
-`--test` (default none): only run the specified standalone test
242
+
-`--test`, `-t` (default none): only run the specified standalone test
233
243
234
244
-`--timeout` (default 30s): set a default timeout for all HTTP requests
0 commit comments