Karate , A Unicorn Test Automation framework

Jigyasa
2 min readJun 1, 2021

Looking at above image, It reminds us of Japenese Martial art. Let’s look at the context of it in testing world.

What is Karate Framework?

As per official website Karate framework defined as:

Karate Framework is the only open-source tool to combine API test-automation, mocks and performance-testing into a single, unified framework.Just write tests in a simple, readable syntax — carefully designed for HTTP, JSON, GraphQL and XML. And you can mix API and UI test-automation within the same test script. Karate is implemented in java but test-scripts are written in Gherkin since Karate was originally an extension of the cucumber framework. It was built within Intuit and released under the MIT License.

Why and when to use Karate Framework?

This framework initially released in 2017. Performance-tests capability via integration with the Gatling tool was released in July 2018. Capability to perform web-UI automation in 2019. It has great future as it enables someone who is not much aware of programming to automate testing.

Karate was featured as one of the top 5 open-source API testing tools within six months of its release.

Features of Karate:

  • Scripts will be written in Gherkin language which requires no prior programming knowledge. Even non programmers can develop scripts.
  • Cross browser Web UI automation so that you can test all layers of your application with the same framework
  • Built-in distributed-testing capability that works for API, UI and even load-testing — without needing any complex “grid” infrastructure
  • Save significant effort by re-using Karate test-suites as Gatling performance tests that deeply assert that server responses are accurate under load
  • Reports include HTTP request and response logs in-line, which makes troubleshooting and debugging easier.
  • Easily invoke JDK classes, Java libraries, or re-use custom Java code if needed, for ultimate extensibility Simple plug-in system for authentication and HTTP header management that will handle any complex, real-world scenario

Sample syntax:

Feature: karate 'hello world' example
Scenario: create and retrieve a cat

Given url 'http://myhost.com/v1/cats'
And request { name: 'Billie' }
When method post
Then status 201
And match response == { id: '#notnull', name: 'Billie' }

Given path response.id
When method get
Then status 200

--

--