-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
[Erlang] add PropEr (property-based testing tool) support #1102
Conversation
Copying the technical comittee @tsloughter |
This is great. Will take me a little bit to fully go over the patch but since it is just adding test code and not touching the generated logic it should be no problem. |
Method = {{httpMethod}}, | ||
Host = application:get_env({{packageName}}, host, "http://localhost:8080"), | ||
Path = ["{{{replacedPathName}}}"], | ||
Body1 = {{^formParams.isEmpty}}{form, [{{#formParams}}{{#required}}{{^-first}}, {{/-first}}{<<"{{baseName}}">>, {{paramName}}}{{/required}}{{/formParams}}]++{{packageName}}_utils:optional_params([{{#formParams}}{{^required}}{{^-first}}, {{/-first}}'{{baseName}}'{{/required}}{{/formParams}}], _OptionalParams)}{{/formParams.isEmpty}}{{#formParams.isEmpty}}{{#bodyParams.isEmpty}}[]{{/bodyParams.isEmpty}}{{^bodyParams.isEmpty}}{{#bodyParams}}{{paramName}}{{/bodyParams}}{{/bodyParams.isEmpty}}{{/formParams.isEmpty}}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
Please use
{{{baseName}}}
instead of{{baseName}}
to avoid special HTML characters being escaped. -
Instead of "Body1", what about naming it as "LocalVarHttpBody"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the comments.
- Fixed.
- Regarding your suggestion I would rather have a short name like
Body
, I think it's closer to the Erlang style, so I renamedBody1
to justBody
since the number suffix didn't make any sense.
@@ -0,0 +1,543 @@ | |||
/* | |||
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech) | |||
* Copyright 2018 SmartBear Software |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
Used to generate PropEr generators for property-based testing
I guess my only question is, shouldn't this be an option on the existing Erlang generator instead of a new one? |
@tsloughter very good question. I think depending on similarity. Personally, I prefer adding an option if the templates are similar with minor differences. |
When I ran
|
@jfacorro can you add the nowarn on export all? And can the statem go in a test or eqc directory? |
@tsloughter I thought about this but decided against it. This is because the templates get unreadable very fast when there are several conditions involved. Having different generators also gives us the freedom to evolve them separately. The HTTP client part in the
@wing328 @tsloughter I added the
@tsloughter Why do you think it would be better to put the statem in a |
@jfacorro thanks for the update. @tsloughter please have another look If no further question/feedback, I'll merge it on the coming weekend. |
@jfacorro PR merged into master. Thanks for your contribution. I've sent out a tweet to proper the enhancement: https://twitter.com/oas_generator/status/1056109614494666752 |
@jfacorro thanks for the PR, which is included in the v3.3.2 release: https://twitter.com/oas_generator/status/1057649626101112832 |
* Generator erlang-proper Used to generate PropEr generators for property-based testing * Fix binary/2 implementation. Add behaviour attribute. * Remove line from copyright notice * Avoid escpaing HTML and remove suffix from variable name * Update samples * Include querystring parameters * We use export_all, don't consider warnings as errors * List command sequence on failure * Use hasConsumes instead * Add nowarn_export_all, re-add warning_as_errors
Used to generate PropEr generators for property-based testing
PR checklist
./bin/
to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.sh
and./bin/security/{LANG}-petstore.sh
if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\
.master
,3.3.x
,4.0.x
. Default:master
.Description of the PR
Creates an Erlang project that can be used to perform property-based testing using the PropEr library. The project includes a client where the request body is generated from the OpenAPI specification.