Karate v0.6.0 Release Notes

Release Date: 2017-09-13 // over 6 years ago
  • ๐Ÿ’ฅ Breaking Change

    match is stricter: data-types have to match

    For example, Karate will no longer treat '5' as equal to 5, 'true' as equal to true and vice-versa. So - this would have failed in previous versions.

    \* def foo = { a: '5', b: 5, c: true, d: 'true' }\* match foo !contains { a: 5 }\* match foo !contains { b: '5' }\* match foo !contains { c: 'true' }\* match foo !contains { d: true }
    

    The new behavior is the right thing to do - especially for a test / assertion framework. There is a good chance that all your existing tests are OK, but think of this as a way to actually surface cases where the server-side is not treating data-types correctly.

    Notable Enhancements

    karate.eval() JS method introduced

    ๐Ÿ— Not recommended for daily use, but you now have the option to dynamically create javascript fragments and evaluate them, and mix them into the right-hand-side of a match expression. Useful if you want to build a custom framework over Karate.

    โœ… Reporting: HTTP logs in-line and call-ed feature steps show up

    ๐Ÿ“ฆ Really improves the trouble-shoot-ability of Karate runs, even if in parallel. Variable values are also dumped on failure. Here is a short video. One more change is that the feature file package + file-name is used as the test-name instead of the text in the cucumber feature, which is way more useful and relevant for API test-suites.

    Gradle instructions

    ๐Ÿ‘€ See doc. Thanks to Mark Corkery for the pull request

    Debug hook to improve IDE debug-ability

    Experimental, but there is a new com.intuit.karate.Debug class designed to be easy to set conditional breakpoints in your IDE. Do let us know if it can be improved.

    Built-in variable called __loop for each data-driven iteration within a call-ed feature

    ๐Ÿ‘‰ Useful especially for this common pattern: to look up a corresponding row from anytable or array in scope, typically a variable def-ined in the parent or call-ing feature.

    Short-cut to denote Json-Path in right-hand-side expressions

    Best explained in this table of Karate right-hand-side expression shapes.

    Short-cut to get[n] single array element out of a Json-Path result

    Again, best explained in this table.

    ๐Ÿ— set on steroids - build complex nested payloads from scratch

    ๐Ÿ“š Quick sample in this gist. Works for XML as well. Refer to the documentation.

    โœ‚ Removed dependency on commons-io and commons-lang3

    โœ… Greatly reduces the risk of conflicts when integrating Karate into existing / legacy test-suites.

    Implemented missing ^^ macro short-cut for contains only

    Here is a nice summary of all syntax as a cheat-sheet.

    Frequently Requested Demos

    • Using JDBC via Java interop and querying a database from within a Karate script.
    • Reading JSON and XML files from the file-system to use in match (or request)

    ๐Ÿ›  Notable Fixes

    #115 form field params should land in the URL on a GET
    ๐Ÿ #126 Karate UI would fail on Windows
    #155 Multiple optional ##(expr) removals in JSON would fail
    ๐Ÿ‘ #157 graphql supported as a text-file extension (thanks to Sunil Sishtla) for the pull request.
    ๐Ÿ›ฐ #163 Optional ##(expr) syntax was not substituting value correctly for non-match scenarios, for e.g. payload formation
    #173 multi-value params for apache - thanks to Matt Johnson for the pull request.
    #175 parallel-executor shuts down threads, avoiding thread / memory leaks
    #179 scenario failures no longer abort the whole feature, other scenarios would still run
    ๐Ÿ”ง #178 configure followRedirects implemented - Karate can be told to not follow-redirects so that you can inspect the Location header if needed