If you would like to get involved in Automated API Testing, but don’t have the programming background, then you might want to give Karate a go!

Karate was released as an open-source tool by Intuit. The tool is designed to be used for automated API testing and has all the required features to make API testing a breeze and actually enjoyable.

Unlike other automated API testing tools which require a fair amount of coding, even just to do basic stuff, Karate works out of the box. You can construct the most complex request-response operations with no knowledge of any programming language. All you have to do is to write the feature file using plain text Gherkin style.

Because Karate is a complete DSL and sits on top of Cucumber-JVM, you can run tests and generate reports like any standard Java project, but instead of writing Java code, you write the tests in a language designed to make dealing with HTTP, JSON or XML easy and simple.

Although there are no pre-requisites to use Karate, it helps if you have the basic understanding of HTTP, JSON, XML, JsonPath and XPath and JavaScript.

In this post, we take a look at some typical operations you would normally perform in Automated API Testing, but first, a quick guide on setting up your environment for Karate.


If you are using Maven, you need the two following dependencies



Alternatively, if you are using Gradle, you need

testCompile 'com.intuit.karate:karate-junit4:0.6.0'
testCompile 'com.intuit.karate:karate-apache:0.6.0'

Folder Structure

A Karate test script has the file extension .feature which is the standard followed by Cucumber. You are free to organize your files using regular Java package conventions.

The Maven tradition is to have non-Java source files in a separate src/test/resources folder structure - but the creators of the Karate tool recommend that you keep them side-by-side with your *.java files.

Like Cucumber, you need to have a “Runner” class which runs the feature file(s). Unlike Cucumber, however, there are no step definitions! And this is the magic of Karate.

To use the TestRunner.java class to execute the feature file, you need to have the build section in the pom.xml file.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
            xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">


And your TestRunner.java class would look like

package com.tutorials.karate;

import com.intuit.karate.junit4.Karate;
import org.junit.runner.RunWith;

public class TestRunner {


Simple Automated API Testing with Karate

Suppose you are testing an API (https://some-api.com/api/users) which returns a list of users in JSON format

        "id": 1,
        "name": "FirstUser",
        "password": "User1Pass"
        "id": 2,
        "name": "SecondUser",
        "password": "User2Pass"

Your Karate feature file will look like:

Feature: Test User API
    Scenario: Fetch all users
    Given url 'https://some-api.com/api/users'
    When method GET
    Then status 200
    And assert response.length == 2
    And match response[0].name == 'FirstUser'

And that’s it - very concise and to the point and most importantly, no code!

Karate comes with a very rich set of useful features which enables you to perform Automated API Testing very easily and quickly. In future posts, we delve more into this amazing tool and give examples on how to do just about anything you need when testing APIs!