This is an extensive tutorial on a relatively new tool in the market i.e ‘Karate DSL‘ library. In this guide, we are going to present solutions to test REST API using Karate which are easily understandable and quick to implement and use.

Karate_Techndeck

Check out: APACHE HTTPCLIENT TUTORIAL with examples (Latest 2022)

Karate DSL was released by Intuit as an open source tool to perform API Testing. Those who don’t know coding, this tool will make their life easier. 

Key Points:

  • It is built on top of Cucumber JVM.
  • Tests are easy to write even for non-programmers.
  • It supports multi-threaded parallel execution.
  • You can generate reports just like any other standard Java project.
  • If you are already using Java and Cucumber in your project, then KarateDSL might be a great choice.

It provides a BDD-like structure to write the code that is one of the advantages of using it as it makes it simple to use.

BDD_Techndeck

Let’s have a quick look at Karate Syntax:

Karate_Code_Syntax_Techndeck

Let’s give you a brief idea here about how the above-mentioned code operates:

a. As per above example, there is no method been passed to given. It means there are no specific preconditions there.

b. There is a ‘get’ method which is being passed to ‘when‘ and it signifies that when we are hitting this URL present in the ‘get’ method, an event occurs. 

c. When we hit the URL in ‘when’, ‘then‘ we are going to receive an output as a response and then we perform validation on it. Here in this particular example shown in the above image, we are performing an assertion on the body by validating the size of an specified element.

Lets jump on the thorough Karate tutorial, here we are going to cover the below topics:

Other Resources:

intuit/karate: Test Automation Made Simple – GitHub

Checkout other useful tutorials (competitors of Karate), take a look:

Rest Assured Tutorial

Apache HttpClient Tutorial