Skip to content
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

Allow invalid request examples #617

Merged
merged 2 commits into from
Mar 4, 2023
Merged

Conversation

joelrosario
Copy link
Member

What:

Examples can now be marked WIP. A WIP example is similar to a WIP scenario, in that if the example fails, it gets logged but is not considered a failure but Specmatic. JUnit will ignore the failure, the return value on the command-line will be 0 (if the failing test from the WIP example is the only failure) and the failure will not break any build.

Why:

There are times when we wish to add an example that should trigger a 400 but instead triggers a 500 (or even a 200 response), and commit this contract to a repo even if the resulting contract test fails. We wish to keep the example so that the feedback is not lost, but cannot afford to break the build as the developer needs time to fix the problem.

How:

  • The Row class now accepts a name.
  • When generating a test from a row, Specmatic now checks if it is a WIP row, if so sets the ignoreFailures flag on the test.
  • Specmatic does not validate an example if it is for a 400 or 422 response. This works only for examples inside a yaml file.

Checklist:

Issue ID:
Closes: #123

Specmatic validates examples that should get a 200 response according to
 the specification. But for an example that triggers a 400 or 422
 response, don't validate it according to the contract. It may be
 necessary to send a contract-invalid request to trigger a 400 or 422
 response.
If a contract test running from an example marked [WIP] fails, it will
 report the failure, but will never fail on the console or in JUnit. As
 a result, no build would break.

This is useful for times when we'd like to put a failing example in the
contract, but the failure cannot be rectified immediately as the
developers are busy or have other priorities.
@joelrosario joelrosario added the enhancement Improvement to an existing feature label Mar 4, 2023
@harikrishnan83 harikrishnan83 self-assigned this Mar 4, 2023
Copy link
Member

@harikrishnan83 harikrishnan83 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

Thanks.

@joelrosario joelrosario merged commit e0fb37f into main Mar 4, 2023
@joelrosario joelrosario deleted the allow_invalid_request_examples branch March 4, 2023 15:35
@joelrosario joelrosario mentioned this pull request Mar 6, 2023
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement to an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants