Botium can be instructed to call a HTTP/JSON API and assert the response within a conversation.
One use case is to verify content of shopping basket within the conversation flow test of an e-commerce chatbot. The ref code for this asserter in Botium is by default HTTP
Assertion Modes
The asserter takes multiple parameters.
-
1st parameter is the URL to call (HTTP GET)
-
(optional) 2nd parameter is the expected output.
-
If not given, verification is done on the HTTP response code only (2xx)
-
Otherwise the response returned from the URL call is compared to this
-
-
(optional) 3rd parameter is a JSONPath Expression to apply
-
If not given, the whole response content is used for assertion
-
Asserting for HTTP response code
#bot
HTTP https://run.mocky.io/v3/9b72d65a-753f-47c8-91f7-9901dfe5ed64
Asserting for full HTTP response
#bot
HTTP https://run.mocky.io/v3/9b72d65a-753f-47c8-91f7-9901dfe5ed64 | { "orderNumber": 1234533, "status": "OK" }
Asserting for parts of the HTTP response
#bot
HTTP https://run.mocky.io/v3/9b72d65a-753f-47c8-91f7-9901dfe5ed64 | 1234533 | $.orderNumber
HTTP https://run.mocky.io/v3/9b72d65a-753f-47c8-91f7-9901dfe5ed64 | OK | $.status
Asserting for plain text HTTP response
#bot
HTTP https://run.mocky.io/v3/fe8362a8-c50f-4dc3-af53-b936d81b8a0a | OK
Base URI
The base URI for all the HTTP calls can be given in the global args for the asserter.
{
"botium": {
"Capabilities": {
...
"ASSERTERS": [
{
"ref": "HTTP",
"src": "botium-asserter-http",
"args": {
"baseUri": "https://run.mocky.io/v3"
}
}
]
}
}
}
The baseUri is prepended to all HTTP calls (if they are not absolute Urls):
#bot
HTTP /fe8362a8-c50f-4dc3-af53-b936d81b8a0a | OK
This is useful for having several environment-specific configurations for this asserter, each one pointing to another server, for example:
* [https://my-api-dev](https://my-api-dev) in the DEV environment
* [https://my-api-sit](https://my-api-sit) in the SIT environment
In Botium, you have to register the HTTP Asserter multiple times and
add them as Registered Component to the Test Projects for each
environment.
Comments
0 comments
Please sign in to leave a comment.