Testing / Karate Framework Interview questions
What is the difference between match == and match contains in Karate?
match == requires the actual value to be exactly equal to the expected value, every key in a JSON object (or every element in an array) must be present and match, with nothing extra and nothing missing. match contains only requires the expected keys or elements to be present, in any order, without requiring the actual value to have exactly those and nothing else.
* def response = { id: 1, name: 'Alice', role: 'admin', createdAt: '2026-01-01' } # fails: response has extra fields (role, createdAt) not listed here * match response == { id: 1, name: 'Alice' } # passes: only checks that these keys exist with these values, extra fields ignored * match response contains { id: 1, name: 'Alice' }
Use == when the exact shape of the response matters and any unexpected extra field should fail the test; use contains when only specific fields matter and the response may legitimately include other fields the test doesn't care about, which is common for APIs that add optional or evolving fields over time.
More Related questions...