-
Notifications
You must be signed in to change notification settings - Fork 532
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
Support for multiple possible status assertions #2035
Comments
Interesting problem! We can see how to adapt the current syntax to deal with it. |
Hi @smokedlinq
|
Another possibility 😊: use
Remind me also of #347 where we discussed about
|
Another possibility:
|
How about an
|
|
For example, reducing the example to one value
it can be ambiguous. Do we have a collection of one value or the string itself is a collection (like in Python)? |
Go for |
I agree that |
Devops that use Python should be happy with |
This brings us back to the issue of naming the jsonSchema validation predicate: do we only use verbs or not ? 🤔 |
This feature would be really nice. The scenario I hit recently was where I had some requests which will set up data for later tests. It would be nice if these setup requests would tolerate the data being in place already, in which case my API will return a 409 status. So I’d have set the assertion to accept 201 or 409. |
Somewhat related to this issue, I was wondering if there is any direction of embedding something like Lua to allow for custom filters, asserts and captures. I was thinking of opening it as a separate issue but it appears that this is one example of a use case. It would also open up the door for a lot more customization. I don't know Rust but I have seen praise for the mlua crate |
Problem to solve
Support asserts for status that could return one or more possible status codes that are valid, e.g. 200, 201, 202, 204, 409. The range status check doesn't work when you want to use a complex set like 200, 424, and 503.
Proposal
Option 1 - Add a
toString
filter so that a matches predicate can be used:status toString matches "^(200|424|503)$"
Option 2 - Add support for a predicate that finds one or more values:
status <some_predicate_expression> [200,424,503]
; some_predicate_expression could be isOneOf, includedIn, isAnyOf, etc.Option 3 - Add support for an array of values to write the includes like:
[200, 424, 503] has status
Additional context and resources
We have an API endpoint we want to test that could return a different response depending on the state of the system. These are valid responses but we don't want to fail the test as long as it is one of the expected statuses.
The text was updated successfully, but these errors were encountered: