-
Notifications
You must be signed in to change notification settings - Fork 196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Feature request - Generate tests from OpenAPI / Swagger yaml or json file #56
Comments
@9fingerdev Could you elaborate a little on what you mean by basic tests? |
Thanks for your reply. One example is a rest api that sends an email and
requires the following data:
- Oauth2 token
- email from address
- email to address
- subject
- message
I'm looking for a solution that would create tests with expected results
for the happy path along with test that omit some off the data. Expecting
the solution to create the test from OpenAPI/Swagger definition file. Is
that something that APIMATIC can do?
…-Troy
On Fri, Dec 1, 2017 at 5:24 AM, Siddhant Sinha ***@***.***> wrote:
@9fingerdev <https://github.com/9fingerdev> Could you elaborate a little
on what you mean by basic tests?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<https://github.com/postmanlabs/postman-app-support/issues/3877#issuecomment-348481862>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AghysMzbG2q27nc-IAZe6vlzTZcM-2Kpks5s7-_zgaJpZM4Qvkgn>
.
|
I'd love to be able to define my postman/newman tests in my openapi spec, then have them brought into my collection after conversion. |
+1 |
Idea: Would a good approach be to generate "basic" tests, that can be defined in a config file? Basic tests that potentially be deducted from the OpenAPi spec:
What else could be based on the OpenAPi spec? |
Added test generation for: - Success status check - Response time check - Content-type check - JSON schema validation - JSON body check
I started on a PR for generating basic tests. I'll make the generation configurable. |
I think I added the feature in my PR #225 Feel free to review the proposal and give feedback. The feature proposal contains 2 implementations:
An example and the properties are explained here: the https://github.com/thim81/openapi-to-postman/blob/develop/TESTGENERATION.md To manage all these settings, the user can provide a test suite JSON file (which I call the "test suite configuration file"). This file can be passed along the CLI with a separate parameter. The test generation for option (1) can be can be added in the test suite configuration file where all information with regards to the preferences for the different tests for option (1) can be managed. This will also allow addition of new basic tests in next versions. The manual test postman scripts are also managed in the test suite configuration file, grouped per OpenApi OperationId. The use-case is to facilitate API CREATE operations with dynamic data, where we provide the option to overwrite/extend the OpenAPI request body, Query params & Path Variables with more specific values or the dynamic variables provided by Postman, desired by the Testsuite. By having the option to overwrite the Query Param, Path variables & headers, it will be easier to automate chaining / workflows as part of the automation. By automatically creating a pm.environment variable based on the response ID property. If the test suite configuration file is not added or if certain best tests are not "enabled". Why I did choose not to add tests in OpenApi spec?
The feature proposal provide a way to add/generate Postman tests based on the OpenApi spec. Looking forward on hearing any feedback or remarks. |
For your information, the test functionality is being used in an CI pipeline and it works great for contract testing via Postman. The flow is defined as following:
This all automated in an Azure Pipeline. |
@daraul @pauloallex24 @9fingerdev @abhijitkane I'm looking for some feedback on the PR proposal. Check #225 for details and some screenshots. Any input or +1 is welcome, so I know i'm on the right track. |
Thanks, @thim81. I can't test right now, so I'll have to take your word for it until I can give it a proper test. |
Added additional options for the test suite generation: An example and the properties are explained here: the https://github.com/thim81/openapi-to-postman/blob/develop/TESTGENERATION.md |
Added additional options to provide the option to define pm.environment variables for automation, by assigning values from the response. Automatically a pm.environment variable for the POST response will be provided. More details: https://github.com/thim81/openapi-to-postman/blob/develop/TESTGENERATION.md#postman-test-suite-assignpmvariables |
This fork is really promising. openapi-generator seems to lack the ability to generate API tests, so this allows me to create forms of automated tests. There seems to be a bug around overwriting request headers. It just doesn't seem to work. It looks like the value faker thing is clobbering the value updated from the example.
There's lots of promise here. Wish I had the time to implement these ideas myself. Keep up the good work! |
Thanks for the input, I appreciate it. With regards to the request headers and the clubbering:
My next steps that I want to look into is:
I have recently enhanced the "schema" matching to bring support the OpenAPI "nullable" option (which was not supported like this in JSON schema validation) (thim81@af070d3) If you have more test suite functions that would come in handy, let me know. |
A short update, I have added the "operation" matching capability (with wildcard support): https://github.com/thim81/openapi-to-postman/blob/latest.2.7.0/TESTGENERATION.md#postman-test-suite-targeting-for-variables--overwrites (which I'll include in my PR after some more testing) next to a number of minor improvements. This will allow targeting assigning variables and overwrites (request body, query params, headers) based on the OperationId or Operation (combination of method & path). For the setting of the authorization, have a look at https://github.com/apideck-libraries/portman which is build on top openapi-to-postman (with my PR) and some more handy functions. It focusses on facilitating automation with options to overwrite certain things. |
UPDATE: I concluded that the PR functionality does not really belong in openapi-to-postman, because this package is focussed on converting OpenAPI to Postman (and does excellent job). Together with Nick from Apideck, we ported the PR contract testing functionality, with plenty more to the Portman package. It supports: contract testing, overwrites, assign variables + variation testing |
UPDATE: We just launched the 1.0 release of Portman, which now support contract, variation & integration testing! |
I would like to see a new feature that creates basic tests for api calls based on OpenAPI/Swagger definition.
The text was updated successfully, but these errors were encountered: