Replies: 1 comment 2 replies
-
hi @jpjpjp I'm trying to fully understand how your setup looks like. Some dummy questions/ideas:
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I've noticed that, without any particular configuration, Portman generates Contract Tests that use the values specified in the examples provided in the OpenAPI spec for request parameter and request body attribute values.
Can these example values be accessed in Portman configuration rules or Postman scripts?
To provide some context in the ask, I've been trying to generate a single test configuration that I can use while I'm designing a new API with a mock service. Our goal is to have a single test configuration that we can run against the mock service in the design phase and then hand it off to the implementation team to validate that their implementation is correct.
The one area where we have struggled is with the Contract Tests. In a real service you typically want your contract tests to dynamically use the id created in a POST request in subsequent RUD operation tests. Portman provides this syntax for making this happen:
However, I don't want to use this dynamic ID from the POST response if I run my test against a mock service with canned data. Instead, I'd like to use the default example values from the spec. In a previous question, I learned that there isn't a way to add any conditional logic to the
overwriteRequestPathVariables
so I decided to work around this problem by using a prerequest script to overwrite, the previously overwritten variable. To do this I add the following to the configuration shown above:Which generates adds this as pre-request script:
Here I'm setting the value of the environment variable that will be used to set the request path parameter on the request back to the example value from my OpenAPI spec. But it is hard coded. This isn't the end of the world, but Portman seems to have the examples available somewhere, I wondered if it was possible access those values in order to make my script more dynamic.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions