Naturally, only one value can be returned. Or - if a call is made without an assignment, and if the function returns a map-like object, it will add each key-value pair returned as a new variable into the execution context. Here below is an example jbang script that uses the Karate Java API to do some useful work. Karate is the only open-source tool to combine API test-automation, mocks, performance-testing and even UI automation into a single, unified framework. Refer to karate.tags and karate.tagValues. A very useful capability is to be able to check that an array contains an object that contains the provided sub-set of keys instead of having to specify the complete JSON - which can get really cumbersome for large objects. Karate, created by Intuit a few years ago, has matured into a stable tool with unique functionality. You can selectively re-direct some HTTP requests that the browser makes - into a Karate test-double ! Also note that you dont use @Karate.Test for the method, and you just use the normal JUnit 5 @Test annotation. In the case of the call of a JavaScript function, you can also pass a JSON array or a primitive (string, number, boolean) as the solitary argument, and the function implementation is expected to handle whatever is passed. You can set this up for all subsequent requests or dynamically generate headers for each HTTP request if you configure headers. Get a cookie by name. Karate is an open-source API (SOAP & REST) testing automation tool written in Java. The .graphql and .gql extensions are also recognized (for GraphQL) but are handled the same way as .txt and treated as a string. A great example of how you can extend Karate, even bypass the HTTP client but still use Karates test-automation effectively, is this gRPC example by @thinkerou: karate-grpc. If the argument passed to the call of a *.feature file is a JSON array, something interesting happens. Might be desirable instead of, useful to brute-force all keys and values in a JSON or XML payload to lower-case, useful in some cases, see, functional-style map operation useful to transform list-like objects (e.g. Add the plugin to the / section of your pom.xml if not already present: If you want to use JUnit 4, use the karate-junit4 Maven dependency instead of karate-junit5. But you can prefix the name with classpath: in which case the root folder would be src/test/java (assuming you are using the recommended folder structure). And path blog?page=2. "b": 2, } The need to wait until some text appears is so common, and with this - you dont need to worry about dealing with white-space such as line-feeds and invisible tab characters. Use a variable in the called feature instead, for e.g. Note how Karate is able to resolve a relative path to an actual OS file-path behind the scenes. returns the last HTTP response as a JS object that enables advanced use-cases such as getting a header ignoring case: returns the last HTTP request as a JS object that enables advanced use-cases such as getting a header ignoring case: get metadata about the currently executing, sets the value of a variable (immediately), which may be needed in case any other routines (such as the, where the single argument is expected to be a, only needed when you need to conditionally build payload elements, especially XML. match each can be combined with contains deep so that for each JSON object a deep contains match is performed within nested lists or objects. There are two types of code that can be call-ed. What we will do is intercept any request to a URL pattern *randomuser.me/* and fake a response. So you could have also done something like: Also refer to the configure keyword on how to switch on pretty-printing of all HTTP requests and responses. You can do so by setting the charset to null via the configure keyword: If you need headers to be dynamically generated for each HTTP request, use a JavaScript function with configure headers instead of JSON. For JUnit 5 you can omit the public modifier for the class and method, and there are some changes to import package names. There are four variations and use the locator prefix conventions for exact and contains matches against the