-
Hi. I've managed to build some contract and variation tests and am now looking into content tests. In reading through the doc and learning the Portman syntax for testing attributes in the response body, I found myself wondering how I could write meaningful tests without knowing what the request parameter or request body is. Upon inspection, it appears that the default behavior for Portman when it generates a request is to use the first example it finds in the OpenAPI spec for the request parameters and request body. Could you please confirm if my understanding is correct? If this behavior is documented, I would greatly appreciate a reference to that part of the documentation. I did find the docs describe the use of overwrites, which seem to work in the following sections:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
hi @jpjpjp Portman uses the "assignVariables" in combination, with overwrite. It does not automatically can detect the primary identifier to be used in CRUD operations, since there is no indication for that in OpenAPI. But using the flow, like described below, you can easily have Portman generate ready-to-use variables and use these when making RUD requests. Have a look at this example (which I used in a meetup): assignVariables:
- openApiOperation: POST::*
collectionVariables:
- responseBodyProp: id
name: <tag>Id
- openApiOperation: GET::*
excludeForOperations:
- "GET::/*/{id}"
collectionVariables:
- responseBodyProp: characters[0].id
name: <tag>Id
overwrites:
- openApiOperation: "*::/*/{id}"
overwriteRequestPathVariables:
- key: id
value: '{{<tag>Id}}'
overwrite: true The part The part For the usage of the assigned variables, we use the "overwriteRequestPathVariables", where we use the same template option as variable name to be insert the request path variable. More examples and docs: |
Beta Was this translation helpful? Give feedback.
hi @jpjpjp
Portman uses the "assignVariables" in combination, with overwrite. It does not automatically can detect the primary identifier to be used in CRUD operations, since there is no indication for that in OpenAPI. But using the flow, like described below, you can easily have Portman generate ready-to-use variables and use these when making RUD requests.
Have a look at this example (which I used in a meetup):
https://github.com/thim81/spec-driven-openapi-contract-performance-testing/blob/main/testing-contract/config/portman-config-flow.yaml