Software:Karate

From HandWiki
Revision as of 04:33, 16 May 2022 by imported>LinuxGuru (fix)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Short description: Test automation framework open-sourced by Intuit
Karate
Karate logo
Original author(s)Peter Thomas
Initial releaseFebruary 08, 2017
Repositoryhttps://github.com/karatelabs/karate
Written inJava
LicenseMIT

Karate is an open-source general-purpose test-automation framework that can script calls to HTTP end-points and assert that the JSON or XML responses are as expected. Karate also has support for service-virtualization where it can bring up "mock" (or stub) servers which can substitute for web-services that need to participate in an integration-test. Karate's capabilities include being able to run tests in parallel, HTML reports and compatibility with Continuous Integration tools.

The additional capability to re-use functional tests as performance-tests via integration with the Gatling tool was released in July 2018[1] The project also added the capability to perform web-UI automation in 2019[2] which was declared out of RC (release-candidate) status in 2020.[3] Support for Microsoft Windows desktop automation was introduced in 2020.[4]

Karate is implemented in Java but test-scripts are written in Gherkin since Karate was originally an extension of the Cucumber framework.

History

Karate was created by Peter Thomas.[5]

Basic usage

This example shows what a simple Karate test script looks like and how it is based on the Gherkin 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

This actually makes two calls, first an HTTP POST to 'http://myhost.com/v1/cats' and then a GET to the same URL but with the value of response.id appended as a REST-ful path parameter. The match keyword is used for asserting that a given payload is as expected. The use of the #notnull "fuzzy match" token takes care of "ignoring" the actual value since it is dynamic, as it is a server-side auto-generated identifier.

Features

  • Although based on Cucumber, Karate does not require the user to write extra "step-definitions", which saves a lot of effort. Tests are fully described in Gherkin.[6]
  • Built-in support for switching the environment[7]
  • Comprehensive support for HTTP, including SOAP/XML, HTTPS, HTTP proxies, URL-encoded form data, multi-part file uploads[7]
  • HTTP API mocks
  • Integration with popular Java unit-testing frameworks such as JUnit[8]
  • Compatibility with continuous integration tools[8]
  • Web-browser automation of Chrome via the Chrome DevTools Protocol[2]
  • Cross-browser automation via the W3C WebDriver specification

Reception

Karate was featured as one of the top 5 open-source API testing tools within six months of its release.[9] It was also mentioned as one of the 10 API testing tools to try in 2017.[7]

Karate was first listed in the ThoughtWorks Technology Radar in 2019[10] with a rating of "Assess". One year later it moved into the "Trial" category in May 2020.[11]

References

  1. "Karate 0.8.0 release notes - which introduced performance-testing". https://github.com/karatelabs/karate/releases/tag/v0.8.0. 
  2. 2.0 2.1 Thomas, Peter. "The world needs an alternative to Selenium - so we built one". https://hackernoon.com/the-world-needs-an-alternative-to-selenium-so-we-built-one-zrk3j3nyr. 
  3. "Karate 0.9.5 release notes - which introduced web-browser automation". https://github.com/karatelabs/karate/releases/tag/v0.9.5. 
  4. "Karate 0.9.6 release notes - which introduced Karate Robot for Windows automation". https://github.com/karatelabs/karate/releases/tag/v0.9.6. 
  5. Thomas, Peter (2017-02-28). "Karate: Web-Services Testing Made Simple". https://medium.com/blueprint-by-intuit/karate-web-services-testing-made-simple-366e8eb5adc0. 
  6. "REST API Testing with Karate | Baeldung" (in en-US). Baeldung. 2017-11-16. http://www.baeldung.com/karate-rest-api-testing. 
  7. 7.0 7.1 7.2 Assertible. "10 API testing tools to try in 2017". https://assertible.com/blog/10-api-testing-tools-to-try-in-2017. 
  8. 8.0 8.1 "Testing a Java Spring Boot REST API with Karate". https://semaphoreci.com/community/tutorials/testing-a-java-spring-boot-rest-api-with-karate. 
  9. "5 top open-source API testing tools: How to choose | TechBeacon" (in en). TechBeacon. https://techbeacon.com/5-top-open-source-api-testing-tools-how-choose. 
  10. "ThoughtWorks Technology Radar Vol. 20 (April 2019)". https://assets.thoughtworks.com/assets/technology-radar-vol-20-en.pdf. 
  11. "ThoughtWorks Technology Radar (Languages & Frameworks) Vol. 22 (May 2020)". https://www.thoughtworks.com/radar/languages-and-frameworks?blipid=201904027. 

External links