Test Automation Made Simple
karate-core
and has to be explicitly added to your Maven (or Gradle) dependencies if you want to use it - as karate-ui
.listen()
on the socket instance, not on the karate
object. You can now juggle multiple websocket connections within a Scenario
. Custom headers can be added and you can change the default message limit, in case you are using large binary websocket payloads.karate-netty
Maven artifact has been retired. The Netty / mocks code has been part of karate-core
since 0.9.0, and in fact if you use karate-apache
(or karate-jersey
) you don't need any additional dependency any more. If you were using only karate-netty
in a project, change it to karate-apache
. The karate-netty
dependency used to include the net.masterthought:cucumber-reporting
dependency, which may have been convenient - but now if you need that reporting solution, you have to add that dependency explicitly.* configure ssl = { trustAll: true }
- the true
here is now a boolean, not a string #772See complete / detailed list of fixes here.
Some kinds of tests would not "complete" leaving some requests missing from the final report and perf stats. Also the tendency to "hang" is fixed.
This is possibly one of the best innovations yet in the Cucumber improvements that Karate brings. Now the Scenario Outline
is tightly integrated with Karate's JSON data-driven capabilities. Read about it in detail here: Scenario Outline Enhancements
Scenario
by name and line-number #770 #773You can now run a Scenario
by name or line-number which is extremely convenient in development mode. While possible in Cucumber, this had been temporarily lost after we dropped the Cucumber-JVM engine.
karate
objectkarate.repeat()
- avoid nasty JS loops to do an action N timeskarate.mapWithKey()
- convenient for the common case of converting an array of primitives into an array of "single key-value pair" JSON-skarate.set()
- set multiple variables in one shot from a JSON / bag of key-valueskarate.merge()
- merge 2 or more JSON / map-like objectskarate.append()
- append 2 or more objects or list-like objects into a single array / listkarate.sizeOf()
- future-proof way to get the size of an object / map or array / list without worrying about the Java type behind the sceneskarate.keysOf()
- future-proof way to get the keys of an object / map without worrying about the Java type behind the sceneskarate.valuesOf()
- future-proof way to get the values of an object / map (or array / list) without worrying about the Java type behind the sceneskarate.appendTo()
- useful for appending items into an existing variable that is expected to be list-like, without worrying about the Java type behind the sceneskarate.exec()
- convenient way to invoke a native OS command and scrape the console outputDo try / contribute if you can !
Karate is one of the few automation frameworks that is Java 12 ready. Note that we have a migration to Graal planned that will ensure support for Java versions beyond 12.
This is a bug-fix release and there are no breaking changes from 0.9.1 (unless you use the Gatling integration, see below) which was released 2 months ago. The main reasons why you should upgrade are the following:
Only if you use Dynamic Scenario Outlines - the HTTP / console log was being missed for some scenarios in the HTML / JSON report.
Some kinds of catastrophic failures especially in the karate-config.js
bootstrap - would cause the parallel runner to hang indefinitely.
In IntelliJ - clicking on the nodes in the IDE UI for JUnit would not show the corresponding section of console output.
We upgraded the Gatling version we target to 3.X which means we are no longer limited to only Java 8. You need to upgrade the Gatling Maven plugin version, and depending on which Gatling features you have used - there may be API changes. Refer to this Github diff for details.
Added support for the sub-protocol part of the spec.
Only if you use the Karate UI - the area in the UI where the log was supposed to collect was not working.
Also we improved the experimental UI automation API, with new driver.switchTo()
and driver.value(set)
operations.
For the complete list of fixes, go here.
This is a bug-fix release and there are no breaking changes from 0.9.0 which was released last month. The 2 main reasons why you should upgrade are the following:
When there were multiple Scenario
-s within a feature, the logs could get mixed up. Note that this bug does not affect the accuracy of test results, but will make it harder to troubleshoot in some cases.
One of the changes in 0.9.0 unfortunately made the match
error message a lot less user-friendly, instead of identifying the exact path to the mis-matched element, you would see a generic message like: all key-values did not match
- and worse, a dump of all sibling data-elements, which could be quite verbose.
There are a few other fixes including a windows path issue for the standalone JAR, see the whole list here.
The 0.9.0 release is a big one. Karate no longer uses Cucumber behind the scenes and the feature-file parser and execution-engine were re-written from scratch. 100% backwards compatibility has been maintained, all your existing tests will run fine - and even IDE support has been preserved.
This took some serious engineering effort, but was totally worth it ! We can now move fast and improve the engine without worrying about the evolution of Cucumber versions. For example, the parallel-runner now executes even Scenario
-s within a Feature
in parallel, and that includes data-driven Examples
within Scenario Outline
-s.
Which leads us to the only possible breaking change you may encounter - Scenarios will be executed in parallel by default. See below.
There are absolutely no breaking changes for syntax and Java API, and it is highly likely your existing Karate tests would run as-is without any changes. But in case you have Scenario
-s that depend on each-other (which obviously is a bad-practice and absolutely NOT recommended) you will have to use the @parallel=false
tag to force them to run in sequence - when using the parallel runner. Just place the tag above the Feature
level in your test-script so that it applies to all Scenario
-s within that Feature
. Read more.
While upgrading, use this opportunity to ensure that your tests are indeed independent and can run in any order !
The documentation has always warned that JUnit is strongly recommended, and we have been announcing this deprecation in advance. This is not going to be an issue because even in the rare chance that you have gone "all in" on TestNG, the Maven surefire plugin supports JUnit and TestNG in the same project. Note that JUnit 5 support has been introduced. Keep in mind that the parallel runner (which is what you will be using most, e.g. for CI) is pure-Java and it does not matter if the runtime is JUnit or TestNG.
The next release will deprecate the @CucumberOptions
annotation and the CucumberRunner
class, please plan to switch to com.intuit.karate.KarateOptions
and com.intuit.karate.Runner
. And com.intuit.karate.Results
will eventually replace KarateStats
. All the examples and documentation have been updated. So this is the recommended pattern:
Results results = Runner.parallel(getClass(), 5);
assertTrue(results.getErrorMessages(), results.getFailCount() == 0);
In fact for tests in dev mode (not the parallel runner), if you start using JUnit 5 you may not need the @KarateOptions
(previously @CucumberOptions
) annotation any more.
On the command line, instead of cucumber.options
- you can start using karate.options
.
To be clear, we will only turn on deprecation warnings in the next release, the old stuff will still work in the next release (1.0) and will stop working (as per plan) only later, in the release after 1.0 - so in short, you don't need to change anything for now.
karate-netty
now part of karate-core
Your existing projects are not affected, but now you no longer need to use the karate-netty
artifact if you want to use mocks or test-doubles, all of that goodness is in the main JAR itself. In other words, when you use karate-apache
, you get the test-doubles capabilities as well.
Already mentioned above, and there is a new HTML report that allows you to visualize the parallel efficiency: see video.
Thanks to the JUnit team and @sormuras for his awesome support and PR-s ! You can have multiple methods in the same test-class which should reduce a lot of clutter in dev-mode. And the API is elegant, nice and DRY. Read more.
Great for demos and de-bugging tests, a big improvement is that you can even step through call
-ed features. You can import Postman collections like before, but that capability is still considered experimental. Please do contribute if you can ! See video. Read more.
Thanks to @babusekaran for some PR-s !
As per the HTTP spec header names should be case-insensitive. You can force all header key-values to be lower-case:
* configure lowerCaseResponseHeaders = true
We also made it easy to take any JSON and brute-force all of it to lower-case, which can be useful in some situations:
* def response = karate.lowerCase(response)
An additional built-in variable responseBytes
will hold the response
as a byte-array, useful when dealing with binary-content. And the match
syntax even works with byte-arrays, no there's no need to do a custom array comparison any more:
And match responseBytes == read('test.pdf')
Similarly, for the test-doubles / karate-netty
side, requestBytes
holds the incoming request
byte-array.
You can now choose a single Scenario
when using the call
(or callonce
) keyword. Just append it to the feature name like so:
call read('classpath:my-signin.feature@sometagname')
The above call tag selector
concept allows you to better compose load tests out of a large suite of existing Karate tests. Two other big improvements are the ability to customize the "report name" of any HTTP request, and to even test any Java code, not just HTTP ! As an example, see the Karate-gRPC project. Read more.
Hide steps in the report when configured or show only steps that don't begin with the *
prefix. Read more
There are certainly not many testing frameworks that support websockets. And with just two API methods: karate.signal(result)
and karate.listen(timeout)
- you can easily set up tests to wait for async events such as message-queues.
Read more
No more messing around with JavaScript loops and an additional file to call
, now provide a condition before the method
step and Karate will do the rest. Read more.
Examples
no longer have to have a fixed number of rows at run-time. Use JSON arrays, that can even be dynamic and created at run-time - but retain the same read-ability and report-friendliness of the Scenario Outline
. Read more.
Karate can now read CSV files out of the box - and as you can imagine this goes really well with the Dynamic Scenario Outlines described above. So if you read()
a file with a *.csv
extension, Karate will convert it into a JSON array, and a header row is always expected. Read more.
You can now use karate.embed(bytes, mimeType)
to embed any kind of content into the test output and these would be viewable in the HTML report. Read more.
You may have heard of Puppeteer and "Headless Chrome" - and guess what, Karate has first-class support for Headless Chrome now ! This sets us up for UI automation (see the next section) but - Karate is probably one of the few libraries out there that gives you the capability to save HTML from a URL you choose - into PNG or even PDF. Read more.
Yes, why not - provided API testing is feature-complete and mature. We strongly feel that if we get this right, and actually solve the problem of "flaky tests", Karate would be a serious force in the world of test-automation. In our opinion, there are quite a few things that give Karate an advantage:
The UI automation capability is deemed experimental as of now and the API can change. We are releasing this so that you can experiment and perhaps be inspired to contribute because of all the above reasons ! Read more.
A big thanks to: @zak905 @vmchukky @thinkerou @loren138 @selzlein @connormca @babusekaran @leozilla and @sormuras.
Here is the complete list of all fixes and enhancements.
This first one only applies if you are using the stand-alone JAR. Previously the command-line option -t
was used to specify the feature file to be run - but now it is used to specify Cucumber tags. There are some big improvements - parallel execution and even reporting are built into the single binary ! Refer to the documentation for more details.
Second: the com.intuit.karate.Debug
class has been removed - while refactoring the engine to get Gatling support to work, but we are pretty sure no one was using this. We can bring this back if needed.
We are releasing this ! This is the first version, but we have people who tried it report back and it seems to be stable. Here is a video of what to expect: link. And here is the documentation. Your feedback can make this better, and we are committed to release minor version upgrades when needed as we evolve this.
To pick one highlight - it is the greatly improved memory usage of the parallel runner. Earlier, teams that had many tests would run into an Out Of Memory error and had to reduce or switch-off log levels to work-around.
map
, filter
and forEach
Also map
, filter
and forEach
operations have been introduced on the built-in karate
JS helper object. This will make it easier to work with JSON arrays or list-like data - very useful for filtering or even transforming one kind of JSON into another. This demo file has some examples.
This makes Karate more accessible for teams that are not really into Java and don't want to use a Java IDE or Maven project structure. The stand-alone JAR can now even run tests in parallel from the command-line and the only pre-requisite is a JRE. You can now recommend Karate for JavaScript, .NET or Python developers without holding back ! This is great for demos as well. Note that the binary has been renamed to karate-<version>.jar
to signify that it has everything in it. Refer to the documentation for all the details.
karate-netty
dependency bundles Netty dependenciesThe test-doubles (karate-netty) project now "shades" the netty JAR which means you can combine Karate mocks into Maven or Gradle projects which already use netty - without any library conflict issues.
bodyPath
helper to make it easier to route incoming requests based on payload contentmatch each
karate.match()
implemented, now you can programmatically do a matchremove
had no effect on XML attributesmultipart fields
introduced that can take a JSON with multiple dynamic values#notpresent
will work as a JsonPath or XPath match even if it is the only RHSThis guide assumes you are upgrading from
0.6.2
, please refer to older release notes if needed.
Karate has had a re-vamp of the JavaScript evaluation engine, which improves execution performance by more than 50%. And Karate has expanded into the area of API test-doubles. Karate is also now available as a single binary (see the link at the top of these release notes), which is useful for starting a mock-server, demos or exploratory testing.
In the process, some significant additions have been made to Karate's syntax plus a couple of carefully considered changes. The good news is that we estimate 80% of existing users will NOT face any issues. Even if you do run into breaking changes - you can breathe easy, as the fixes are very simple and likely to be addition of a single character, or at the most - a single line.
Important: Please do provide feedback if you run into any other issues ! Note that a good way to keep up to date with releases and other news is to follow us on Twitter @KarateDSL.
1.8.0_112
or greaterThis should not be an issue for most teams and it is quite likely that you are already on a recent enough version. But do check, and the problem that you can run into will look like this:
java.lang.RuntimeException: evaluation of karate-config.js failed:
at com.intuit.karate.ScriptContext.<init>(ScriptContext.java:150)
...
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: com.intuit.karate.exception.KarateException: javascript function call failed:
ReferenceError: "karate" is not defined
:white_check_mark: Short Fix Description: Upgrade to the latest version of the Java 8 JRE.
response
needs to be pre-fixed with $
on the RHSKarate used to attempt to 'auto-detect' JsonPath (and XPath) on the Right-Hand-Side of Karate Expressions. For example this used to work:
* def foo = bar[*].id
This had some non-ideal consequences, for example if you wanted to get the length of bar
, you would have to 'force' JavaScript evaluation, by wrapping in parentheses:
* def len = (bar.length)
Now, Karate 'defaults' to always expecting JS on the R.H.S. This has multiple advantages, there is no more 'guesswork' and trial-and-error needed, and the parsing logic became simpler and runs faster. So the above two lines can be now written like this. Prefxing a variable with $
tells Karate to use JsonPath instead of JS:
* def foo = $bar[*].id
* def len = bar.length
Note that $
still represents the response
and JsonPath in the form $.foo
will continue to work like always.
Similarly for XML, /
still represents the response
. You will need to use the $varname
form for XPath on a variable which is not the response
, like so:
* def documentId = $myXml/root/EntityId
Note that there is no change to the get
syntax. Just that $varname[*].id
is now an alternative to get varname[*].id
.
:white_check_mark: Short Fix Description: All you need to do is prefix a $
where necessary.
#null
is stricter, key must be presentKarate used to treat all the following as 'equal' when doing a match
.
{}
{ foo: null }
{ foo: '#null' }
Not any more. So if you were using #null
and you want to match even when the key is not present, just use the 'optional null' marker.
* def test = {}
* match test == { foo: '##null' }
Note that #present
and #notpresent
have been newly introduced and take care of all the possibilities.
:white_check_mark: Short Fix Description: All you need to do is prefix a #
where necessary or use '##null'
instead of an expected null
or just use #ignore
.
call
will not re-use or "share" variablesThere was a bug in the implementation of call
where variables could be over-written by the 'called' routine even when not using 'shared scope'. The most likely situation where you may run into issues is when:
configure headers
with a JS function in your 'main' featurekarate.get()
)If you had faithfully followed the 'sign-in' example in the main Karate documentation, you might have this issue and the documentation has been updated to make clear what the 'right thing to do' is. Just refer to the table at the end of the section on shared scope.
:white_check_mark: Short Fix Description: Either duplicate the configure headers
line in the 'called' feature (easy fix), or switch to using shared scope
(recommended).
charset=utf-8
in the request Content-Type
header by defaultThis is expected to be the intent almost all the time. You can over-ride this per-request by setting the header
, for example * header Content-Type = 'application/xml;charset=ISO-8859-15'
. To set the request charset
'globally', use the configure charset
keyword.
In rare cases, the server may be unable to handle a charset
appearing in the Content-Type
header, and we encountered this once when the entity happened to be part of a multipart request. This actually can be considered as a bug in the server but you can work around this case by setting * configure charset = null
before the HTTP request is made.
:white_check_mark: Short Fix Description: Set * configure charset = null
only if you run into a situation where the server doesn't like a charset
appearing in the Content-Type
header (which should ideally be fixed on the server).
plugins
if specified for the JUnit runner will be ignoredMost users will not be impacted by this. But if you use something like @CucumberOptions(plugin = {"pretty", "json:target/cucumber/cucumber-data"})
in conjunction with the JUnit runner, the value of plugin
(or format
) if specified will be ignored. With Karate, all you need is either the parallel runner (which emits the JUnit XML and the Cucumber standard JSON which most CI and third-party reporting tools can consume) or the HTML report.
:white_check_mark: Short Fix Description: If you were relying on JSON like in the example above, switch to the parallel runner, which is more suited for API tests. Else you don't need to change anything, and the value of plugin
will be silently ignored.
Content-Type
headerafterScenario
and afterFeature
'hooks', and you can get access to test metadata such as the feature file name and scenario name via karate.info
copy
keywordeval
keywordkarate.read()
of JSON within a JS function would not 'cross over' (fixed)karate.callSingle()
Content-Type
header (only supported in Apache)form-field
and header
would re-set headersconfigure charset
which defaults to utf-8
so existing tests should work un-changed, also see #302
match contains any
We hope you like the new logo !
table
keyword will omit keys with null values from resulting JSONIt is quite unlikely you will face issues with the new behavior, but. Empty cells or expressions that evaluate to null
will result in the key being omitted from the JSON. To force a null
value, wrap it in parentheses:
* def one = { baz: null }
* table json
| foo | bar |
| 'hello' | |
| one.baz | (null) |
| 'world' | null |
* match json == [{ foo: 'hello' }, { bar: null }, { foo: 'world' }]
The main reason why you may want to upgrade. This should greatly improve the ease of trouble-shooting a Karate test in your IDE in dev-mode. You need to use the JUnit Runner. Here is a video of what to expect: link.
Karate is actually a perfect fit for testing GraphQL API-s and a new example was added to the demo suite to show-case this capability: graphql.feature
.
#136 callonce
now works when using IDE runner (Eclipse and IntelliJ)
#216 Apache HTTP Client does not follow POST redirects by default - fixed
#229 Apache HTTP Client not allowing cookies with dots in the 'domain' - fixed
#232 built-in variables __arg and __loop not set if using shared-scope - fixed
#223 HTTP response not recognised as JSON if it begins with a newline - fixed
#239 Failed scenarios in called features will now have Scenario name included in the exception / log
#244 XML with DTD would fail - fixed
#246 Parallel runner not honoring logback config - fixed
#248 Schema-like validation should support JSON chunk references which are optional - fixed
#226 Actual HTTP request made (especially headers and payload) can be now be retrieved within a test - which makes writing a framework over Karate easier. There's a new karate.prevRequest
property on the built-in karate
JS object
#253 Karate runner Java 8 updates - thanks to Srinivasan Sekar
Additional boolean
argument, true
to process (and false
to skip) the evaluation of karate-config.js
at the start.
_$
instead of $
for match each
In case you were using $
for cross-field validations combined with a match each
, the concept of a 'self parent' was introduced, since you may still need the 'real' root $
. Refer to the documentation.
Yes, finally. Making sense of the console logs used to be difficult when scripts failed, and Karate used to dump a lot of un-necessary stack-traces. Not any more. Failures now are reported in as few lines as possible, line-breaks are included to make it easier to read (instead of scrolling around for very long lines) and the offending line number and feature-file name are clearly shown. Do submit feedback if you see any opportunities to improve further !
__arg
refers to call
argument #206Yes, we should have had this earlier. While all key-values are 'unpacked' into the context of the 'called' feature, it does make sense to be able to access the passed-in argument as-a-whole. Refer to the documentation. This is a nice companion to __loop
which was introduced in the previous release.
Handling SSL without needing a certificate was broken in some cases. In case you were having to use a certificate for HTTPS, do try setting * configure ssl = true
and it should now work without needing a certificate.
You can ask Karate for the values of all tags in scope. And for advanced users, Karate now natively supports tags with values in the form @name=value1,value2
. Tag 'inheritance' works as you expect since in Cucumber, you can have tags at the level of a Feature
, Scenario
or Scenario Outline
and even for rows within Examples
. The possibilities are best explained in this example: tags.feature
For even more advanced users, there is a way in which you can set up custom tag filtering. Thanks to Sunil Sishtla for the pull request.
print
now takes comma delimited arguments #190Which means you no longer need to use karate.pretty()
in most cases. Refer to the documentation.
set
keyword can append to JSON arrays #189* def foo = {}
# you can update json arrays (or create them automatically)
* set foo.bar[0] = 5
* match foo == { bar: [5] }
# omit the array index to append
* set foo.bar[] = 6
* match foo == { bar: [5, 6] }
And decimal-places reined in.
====================================================
elapsed time: 3.62 | total thread time: 13.79
features: 31 | threads: 5 | efficiency: 0.76
scenarios: 70 | failed: 0 | skipped: 0
====================================================
!contains
(not contains) for strings now works #201!=
(not equals) implementedYou won't need this most of the time, but still.
charset
now supported in the Content-Type
header #203When you use the @RunWith(Karate.class)
annotation, an HTML file will be generated in the target/surefire-reports
directory. As of now, it is not useful - but we will be enhancing this to make troubleshooting in dev easier. The long-term goal is to have HTML reports 'native' to Karate that better reflect API-testing concerns.
match
is stricter: data-types have to matchFor 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.
karate.eval()
JS method introducedNot 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.
call
-ed feature steps show upReally 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.
See doc. Thanks to Mark Corkery for the pull request
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.
__loop
for each data-driven iteration within a call
-ed featureUseful 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.
Best explained in this table of Karate right-hand-side expression shapes.
get[n]
single array element out of a Json-Path resultAgain, best explained in this table.
set
on steroids - build complex nested payloads from scratchQuick sample in this gist. Works for XML as well. Refer to the documentation.
commons-io
and commons-lang3
Greatly reduces the risk of conflicts when integrating Karate into existing / legacy test-suites.
^^
macro short-cut for contains only
Here is a nice summary of all syntax as a cheat-sheet.
match
(or request
)#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
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 quotesRefer 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.
Background
worked only for the first Scenario
Especially if you are mixing call
or callonce
with header
or configure headers
.
.com
domainsFixed.
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.
Yes, this should have been done sooner.
call
and callonce
can update 'global' shared variables and configThis 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
introducedNot 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 addedThis is very useful if you have to perform a lot of text-replace. Refer to the documentation
remove
keyword addedFor deleting JSON keys or entire XML nodes from a payload. Refer to the documentation.
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.
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 objectHas 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
Especially for projects dealing with SOAP and namespaces. This file should be a handy reference: xml.feature
.
contains
macro shortcutA missing piece in the JSON schema-like validation short-cuts. Refer to the last paragraph in this section of the documentation - Schema Validation.
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.
This is another big one ! Details here.
If you are interested refer to this thread.
Thanks to @rishabhbitsg for the pull requests !