v0.5.0
Breaking Changes
There are a couple of breaking changes. Please read this section carefully so that your upgrade goes smoothly.
responseCookies instead of cookies
Hopefully most users would not be referring to cookies, but if you are - the 'built-in' variable name has been changed to be consistent with the others such as responseHeaders, responseStatus and the like, and to avoid confusion with the cookie and cookies keywords for setting up the request.
A simple find-and-replace (where necessary) is all you need to do. Here is the documentation.
table - strings need to be enclosed in quotes
Refer to the documentation - this makes sense, because Karate is all about dynamic data. If you need the traditional Cucumber table experience, just use the Scenario Outline and Examples like normal.
Notable Fixes
Headers (and cookies) set in the Background worked only for the first Scenario
Especially if you are mixing call or callonce with header or configure headers.
#103 - Apache client was skipping cookies on .com domains
Fixed.
#110 - File-upload now supports setting the filename
A new multipart file syntax was introduced. The old behavior where a file-stream passed to multipart field would 'short-cut' into a file-upload will still be supported (to reduce pain for those upgrading) - but we will deprecate this at a later date.
Enhancements
Failures in called scripts now log the called script name
Yes, this should have been done sooner.
call and callonce can update 'global' shared variables and config
This is a little subtle, but can dramatically reduce the 'noise' in your top-level script that does the main 'business' flow. You can move all the setup 'clutter' into called scripts. Refer to the documentation for more.
configure cookies introduced
Not something you would use often since responseCookies are auto-added to all subsequent requests. Unless response cookies were encountered in a 'called' script in which case the item above may be part of the answer. Refer to the documentation.
replace keyword added
This is very useful if you have to perform a lot of text-replace. Refer to the documentation
remove keyword added
For deleting JSON keys or entire XML nodes from a payload. Refer to the documentation.
HTTP Mock Servlet
A big one ! Test any Java servlet based controller (e.g. Spring MVC, Jersey JAX-RS) without booting a container. Refer to the documentation.
This also introduced an option to configure a custom HTTP Client implementation, details which are in the above link.
Type Conversion supports Java Beans (or POJO-s)
Yes you can convert any Java Bean into JSON or XML. Refer to the documentation
And if you need to go the other way, look at karate.toBean() in the next section.
karate built-in JS object
Has a few more operations available on it:
karate.remove(name, path)karate.jsonPath(json, expression)karate.read(filename)karate.pretty(value)karate.prettyXml(value)karate.toBean(json, className)
Refer to the documentation
XML manipulation improvements
Especially for projects dealing with SOAP and namespaces. This file should be a handy reference: xml.feature.
contains macro shortcut
A missing piece in the JSON schema-like validation short-cuts. Refer to the last paragraph in this section of the documentation - Schema Validation.
Remove If Null
A common need, which is to fully remove a JSON key or XML node (or attribute) from a given baseline payload - that now has an elegant solution. Refer to the documentation.
Karate UI and Postman Import
This is another big one ! Details here.
Draft Spring REST Docs Support
If you are interested refer to this thread.
Thanks to @rishabhbitsg for the pull requests !