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
[feature request] Support for #notpresent
keyword
#270
Comments
@avpavlov actually there is an |
|
In other words, |
would |
I meant |
Thank you, both work - However, I would say working
|
Yes. Or how about this, to check for a null just use * def foo = { }
* match foo == { a: null } In my experience, most teams assume a null value and the key missing to be the same. Typically people set the Json marshaller config to 'strip nulls' for example, to reduce payload bloat. Can you help by suggesting what change you'd like to see in the contains readme section, I'll be happy to add. |
Sounds good
That's true. That's why
Let me think |
@avpavlov cool, I'm beginning to agree. see I'm quite reasonable how about |
|
great ! looking at it now. are you able to build from source or do you prefer a release. |
Created PR for |
I can build from sources |
the behavior of match for #null and even the 'null' value has changed, the key is expected to be present in both cases so upgrading may need to use #ignore instead of #null in some rare cases
@avpavlov yes, is now in the develop branch. I actually decided that both |
I agree, Karate tests output/protocol not how this output could be interpreted by consumer |
#undefined
keyword#notpresent
keyword
Just tested project with |
@avpavlov not sure, but you can watch the project on GiHub. there's a twitter account if you are in to that kind of thing: https://twitter.com/KarateDSL |
@avpavlov well. after thinking about it, it made sense to implement * def foo = { }
* match foo != { a: '#present' }
* match foo == { a: '#notpresent' }
* match foo == { a: '#ignore' }
* match foo == { a: '##null' }
* match foo != { a: '#null' }
* match foo != { a: '#notnull' }
* match foo == { a: '##notnull' }
* match foo != { a: null }
* def foo = { a: null }
* match foo == { a: '#null' }
* match foo == { a: '##null' }
* match foo != { a: '#notnull' }
* match foo != { a: '##notnull' }
* match foo == { a: '#present' }
* match foo == { a: '#ignore' }
* match foo != { a: '#notpresent' }
* def foo = { a: 1 }
* match foo == { a: '#notnull' }
* match foo == { a: '##notnull' }
* match foo != { a: '#null' }
* match foo != { a: '##null' }
* match foo == { a: '#present' }
* match foo == { a: '#ignore' }
* match foo != { a: '#notpresent' } |
@ptrthomas When I am validating schema using Karate one of the field as per schema is defined as String but its returning null but it returns string value also in some cases so when its returning null its failing my test as its string. How to handle this. I want it to pass if its null or string when its string in schema. |
@Shaileshz204 use stack overflow for questions like this please: https://stackoverflow.com/a/71522605/143475 |
Use case: I'm writing tests for Spring Boot Repository. It supports "projections" so user can request different detalization, e.g.
I cannot check contains/!contains with single JSON so right now my tests look like
With new keyword added my scenarios will be cleaner and easier to read
The text was updated successfully, but these errors were encountered: