Questions tagged [karate]

Use for questions regarding Karate, an open-source tool that combines API test-automation, mocks, performance-testing and UI automation - into a single, unified framework.

Karate is the only open-source tool that combines API test-automation, mocks, performance-testing and UI automation into a single, unified framework.

Karate uses a language-neutral BDD syntax, which is easy for even non-programmers. Besides powerful JSON & XML assertions, you can run tests in parallel for speed - which is critical for HTTP API testing.

You can easily build (or re-use) complex request payloads, and dynamically construct more requests from response data. The payload and schema validation engine can perform a 'smart compare' (deep-equals) of two JSON or XML documents, and you can even ignore dynamic values where needed.

Test execution and report generation feels like any standard Java project. But there's also a stand-alone executable for teams that are not comfortable with Java. Just write tests in a simple, readable syntax - carefully designed for HTTP, JSON, GraphQL and XML.

4221 questions
4
votes
1 answer

Karate framework retry until not working as expected

I'm using Karate framework with JUnit. Using this feature: Given path 'save_token' And request """ { "token": "test_token" } """ And retry until response.tokens == """ [ "test_token" ] """ When method POST I'm having this…
italktothewind
  • 1,950
  • 2
  • 28
  • 55
4
votes
1 answer

Is it possible to send args to an afterScenario function?

I saw in the doc that it it possible to define a function in the background part and execute it after each scenario. see: https://github.com/intuit/karate/blob/master/karate-demo/src/test/java/demo/hooks/hooks.feature But i need to send args to this…
4
votes
2 answers

Karate: How to test multipart form-data endpoint?

I have an file upload endpoint (/document) in a controller defined as follows: @RestController public class FileUploadController { @Autowired private PersonCSVReaderService personCSVReaderService; @PostMapping(value = "/document",…
joe
  • 220
  • 2
  • 11
4
votes
1 answer

Karate API : How to hit an endpoint url with post method which does not have request body

I am getting below error when I am trying hit a endpoint url with post method which does not have a body. In postman I am able to hit endpoint url with post method without body. I tried all steps by referring the Karate API docs. **Error** :…
sam
  • 289
  • 7
  • 19
4
votes
2 answers

Karate - Setting global request headers

So I've managed to write a bunch of tests and in every feature file I set the same request headers. For example: Given url appUrl And path '/path' * header Accept = 'application/json' I'd like to know if there's a way to set a header once so that…
Rod Bailey
  • 107
  • 1
  • 1
  • 7
4
votes
1 answer

I want to pass multiple arguments in karate-config.js through mvn command

I want to want pass multiple arguments in mvn command and and that should be read in karate-config.js file. e.g: mvn test -DargLine="-Dkarate.env='gdcStaging', -Dkarate.source='false', -Dkarate.natco='gdc'" I didn't want to declare any .prop files,…
shivam
  • 61
  • 8
4
votes
1 answer

karate - how to validate that param is string and having max length

In karate, how to check if in the response, name field is string type and having max length upto 35. I know how to validate, string, but don't know how to check the length at same time. name: '#string',
Renu
  • 303
  • 3
  • 14
4
votes
2 answers

How to get response HTTP status from Karate Call? Getting response status as 204 but karate.log(result.response) is blank

I'm calling a webservice through Karate API. When the service is executed, I am getting HTTP status 204 which is expected. However, when I log the response, I get blank. Below is my webservice call, response and log output result =…
JMD
  • 337
  • 4
  • 16
4
votes
1 answer

Using multiple tags to run in karate options

Let's say I have 4 feature files which is written in karate version 0.9.0. I am tagging feature 1 with @F1, feature 2 with @F2, feature 3 with @F3, feature 4 with @F4. On the other hand, I have a runner class which is placed in the root all of those…
Prometheus
  • 1,522
  • 3
  • 23
  • 41
4
votes
1 answer

How to use dynamic values for Karate Features

I've a need where I should use dynamic values in the features of my karate tests. I've came accross with some of the questions and answers like this: How to read input data from an excel spreadsheet and pass it JSON payload in karate framework? But…
Prometheus
  • 1,522
  • 3
  • 23
  • 41
4
votes
1 answer

How can I send just 'application/json' as the content-type header with Karate?

I'm trying to write my first test for a service that I have no control over. The service validates headers on incoming requests and for the content-type header it requires that the value be application/json, and only that value. However when I try…
nybblesAndBits
  • 273
  • 2
  • 9
4
votes
1 answer

Can I pass values from one feature file of one folder to another feature file of another folder under /src/java/test using karate dsl

My project structure is something like this: /src/java/test TestRunner -> main.java Component1 --> Admin.feature Component2 --> Publisher.feature Component3 --> Store.feature I want to pass some value from Admin.feature file to Publisher.feature…
Sneha Shukla
  • 373
  • 1
  • 4
  • 19
4
votes
2 answers

How to retrieve all values for a particular key in karate

How to retrieve partNumbers from below response. In below response "10000061","10000062","10000063" are dynamic in nature. I have to match these partNumbers with data table partnumbers.( In a response there could be more than 10 part…
sam
  • 289
  • 7
  • 19
4
votes
1 answer

Using mocks in Karate DSL feature file with stanalone run

I have REST service, written in language different from Java. It have few dependencies from other REST services. For example service under development and testing is A, other services are respectively B and C. I want to run system test for A, some…
4
votes
1 answer

#ref:java.util.LinkedHashMap error in Karate tool

* def template1 = {"name1":"value1", "name2":"value2"} * def template2 = template1 * Def jsontemplate = ({json1: template1, json2:template2}) * Print jsontemplate Result : "json1": { "name1": "value1", "name2": "value2" }, "json2":…