karate
karate copied to clipboard
Karate contains only shortcut fails in v1.2.0 contains deep steps
I'm updating karate v1.01 to v1.2.0. This small scenario will fail in karate v1.2.0 but will succeed in v1.0.1
@test_contains_only
Scenario: Test contains only shortcut
* def expected = [ "a", "b", "c", "d" ]
* def to_match = { "properties": { "additional_information": "Some put-updated info", "types": [ "a", "b", "c", "d" ] } }
* match to_match.properties contains deep { "types": '#(^^expected)' }
The same behavior was spotted on my side for additional contains shortcuts, e.g. ^+
and ^*
.
@CleanHit thanks, I really appreciate the simple example
@ptrthomas you're welcome. I see that there was a discussion about this behavior in this https://github.com/karatelabs/karate/issues/1721 issue. The reporter had the same problem as me with v1.1.0. If the intended behavior is not to mix contains deep
with other contains shortcuts, then this issue can be closed.
I'm not that familiar with the code, but I guess that everything that has to do with matchers is being handled in those files
- karate-core/src/main/java/com/intuit/karate/Match.java
- karate-core/src/main/java/com/intuit/karate/MatchOperation.java
- karate-core/src/main/java/com/intuit/karate/MatchStep.java
Since this behavior was spotted in the change from v1.0.1 to v1.1.0, I've compared the two releases. The only #
related changes that I could see were done in karate-core/src/main/java/com/intuit/karate/MatchOperation.java file. I don't know if moving the block in lines 185 - 197 to lines 217 - 229 might have caused this behavior.
EDIT:
After looking at the error I'm getting "all key-values did not match, expected has un-matched keys - [types] (MAP:MAP)", I think it might be more related to the changes done in the private boolean matchMapValues()
function (https://github.com/karatelabs/karate/blob/v1.1.0/karate-core/src/main/java/com/intuit/karate/MatchOperation.java), The only visible changes are in lines 504 - 513.
@CleanHit thanks for the hints, it helped. is fixed in develop
@ptrthomas Thank you. I'll try to test it on my side as soon as the change will be part of some Gradle release candidate package.
@ptrthomas I'm closing this ticket as I've successfully tested it with 1.3.0.RC2
.
@CleanHit thank you ! we follow a (what I realize may be a non-typical) process where we mark as fixed
and close when the final non-RC release goes out, release notes and all, so I'll keep this open for now
1.3.0 released