SlideShare a Scribd company logo
Peter Thomas | Architect | Intuit
@ptrthomas | @KarateDSL
Karate
Web Service API Testing Made Simple
Bangalore 7th Edition
September 9, 2017
Intuit Open Source
Released 09-Feb-2017
A DSL for writing web-service acceptance tests
Built on Cucumber | BDD syntax
Karate github.com/intuit/karate
3
Karate in the top 5 OSS API Testing Tools (TechBeacon)
Tool Inception Years
REST-assured 2010 7
Postman 2012 5
SoapUI 2005 12
JMeter 1998 19
Karate 2017 0.5
4
• Easier to Write
• Readable and Concise
• Faster Execution
• Better Assertions
• Integrates into existing CI / CD
API-tests with Karate
Developer
Productivity
Maintain-
ability
Quality
5
Many teams use Java for writing HTTP-API regression tests.
Java is not the best language to manipulate JSON / XML.
Consequences:
• Over-dependence on Java objects for building and validating
data-payloads
• Object-equality checks done by hand, effort-intensive
• So tests end-up taking “short-cuts”, and don’t validate the full
response, coverage & quality suffers
• Proliferation of helper methods, code bloat & in-house layers
• Result: poor Dev Productivity & Maintainability
Current State of Web-API Testing
• DSL laser-focused on HTTP
• JSON and XML are “first-class”
citizens of the syntax
• Compare deeply-nested payloads
in a single step
• 3:1 Reduction in Lines of Code
• Tests are super-readable and
concise
• Testing is Easier & actually Fun
Karate’s Solve
6
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
Hello World
Intuitive DSL
for HTTP
Payload
assertion in
one line
Second HTTP
call using
response data
JSON is ‘native’
to the syntax
7
Java
vs
JSON
8
Validation examples: JsonPath & RegEx
Type Directive
Ignore / Exists #ignore | #null | #notnull
Primitive Type #boolean | #number | #string
Complex Type #array | #object
Special #uuid
RegEx #regex <regex string>
Predicate #? <expression>
9
JSON ‘templating’
Type Directive
Replace #(<expression>)
10
XML and XPath
11
Comparison with REST-assured
http://tinyurl.com/karateraREST-assured Karate
Plain Text ❌ (needs compilation) ✅
Parallel Execution ? (partial) ✅
Data Driven Testing ❌ (needs TestNG etc.) ✅ (built-in)
Environment Switching ❌ ✅ (built-in)
Match full payload in one step ❌ ✅
Update JSON payload / object ❌ ✅
@Test public void
lotto_resource_returns_200_with_expected_id_and_winners() {
when().
get("/lotto/{id}", 5).
then().
statusCode(200).
body("lotto.lottoId", equalTo(5),
"lotto.winners.winnerId", containsOnly(23, 54));
Scenario: lotto resource returns 200 with expected id and winners
Given path ‘lotto’, 5
When method get
Then status 200
And match $.lotto.lottoId == 5
And match $.lotto.winners[*].winnerId contains only [23, 54]
given().
param("key1", "value1").
param("key2", "value2").
when().
get("/somewhere").
then().
body(containsString("OK"));
Given param key1 = ‘value1’
And param key2 = ‘value2’
And path ‘somewhere’
When method get
Then response contains ‘OK’
Detailed Comparison
12
13
Metrics – port of an open-source example
Reduction of lines of code from 431 à 67
Link: https://github.com/mwinteringham/api-framework/pull/3
14
Components
Karate DSL interpreter
(Cucumber “Step Definitions”)
HTTP Client
Abstraction
JSON XML
JS
Engine
(Nashorn)
Karate ScriptJUnit /
Test NG
(Runner)
Java8JRE
HTTP/S calls
Cucumber-
JVM
Data / Assertions
match, get, set
Reports
Apache Jersey
15
The “missing” Cucumber Features that Karate adds
Capability Cucumber Karate
Step Definitions built-in, no Java code needed ❌ ✅
Re-Use Feature files from other Features ❌ ✅
Dynamic Data-Driven Testing ❌ ✅
Parallel Test Execution and Reporting ❌ ✅
Option to run routines only once per Feature ❌ ✅
16
Example Report
Demos
18
Karate UI (Alpha)
19
• Scripts are plain-text, no compilation or IDE required
• REST as well as SOAP support
• Assert, manipulate, compare and re-use JSON / XML
• User defined functions (Java or JavaScript)
• Configuration switching (e.g. dev | e2e | pre-prod)
• Simple ‘plug and play’ HTTP Header & Auth management
• Comprehensive HTTP support: SSL, Proxy, File-Upload
• JUnit XML reports compatible with all CI tools
• Speed - Parallel Execution of Tests
• Mock Servlet – test without starting a container
Karate Features
BDD
Full HTTP
CI / CD
Ready
Q & A
https://github.com/intuit/karate
@ptrthomas | @KarateDSL
Thank You !
Extra Slides
22
CI Report
(Jenkins)

More Related Content

What's hot (20)

PPTX
RESTful API Testing using Postman, Newman, and Jenkins
QASymphony
 
PDF
API TESTING
Sijan Bhandari
 
PDF
POST/CON 2019 Workshop: Testing, Automated Testing, and Reporting APIs with P...
Postman
 
PPTX
Rest assured
Varun Deshpande
 
PPTX
API Testing for everyone.pptx
Pricilla Bilavendran
 
PDF
API Testing. Streamline your testing process.
Andrey Oleynik
 
PPTX
Test Design and Automation for REST API
Ivan Katunou
 
PPTX
API Automation Testing Using RestAssured+Cucumber
Knoldus Inc.
 
PPTX
Api Testing
Vishwanath KC
 
PDF
API Testing
Bikash Sharma
 
PPTX
Karate for Complex Web-Service API Testing by Peter Thomas
intuit_india
 
PPTX
API Testing Using REST Assured with TestNG
Siddharth Sharma
 
PPTX
Api Testing
Vishwanath KC
 
PPTX
Karate DSL
anil borse
 
PDF
Postman & API Testing by Amber Race
Postman
 
PDF
4 Major Advantages of API Testing
QASource
 
PDF
Reasons To Automate API Testing Process
QASource
 
PPTX
B4USolution_API-Testing
b4usolution .
 
PPTX
Test your microservices with REST-Assured
Michel Schudel
 
PDF
Postman
Igor Shubovych
 
RESTful API Testing using Postman, Newman, and Jenkins
QASymphony
 
API TESTING
Sijan Bhandari
 
POST/CON 2019 Workshop: Testing, Automated Testing, and Reporting APIs with P...
Postman
 
Rest assured
Varun Deshpande
 
API Testing for everyone.pptx
Pricilla Bilavendran
 
API Testing. Streamline your testing process.
Andrey Oleynik
 
Test Design and Automation for REST API
Ivan Katunou
 
API Automation Testing Using RestAssured+Cucumber
Knoldus Inc.
 
Api Testing
Vishwanath KC
 
API Testing
Bikash Sharma
 
Karate for Complex Web-Service API Testing by Peter Thomas
intuit_india
 
API Testing Using REST Assured with TestNG
Siddharth Sharma
 
Api Testing
Vishwanath KC
 
Karate DSL
anil borse
 
Postman & API Testing by Amber Race
Postman
 
4 Major Advantages of API Testing
QASource
 
Reasons To Automate API Testing Process
QASource
 
B4USolution_API-Testing
b4usolution .
 
Test your microservices with REST-Assured
Michel Schudel
 

Similar to Karate - Web-Service API Testing Made Simple (20)

PPTX
Karate - MoT Dallas 26-Oct-2017
Peter Thomas
 
PDF
apidays LIVE India - Karate for REST and GraphQL test automation by Peter Tho...
apidays
 
PDF
Wax on, wax off
Bol.com Techlab
 
PDF
API Test Automation using Karate.pdf
Venessa Serrao
 
PDF
Karate API Testing-Complete Guidance by Testrig
PritiFGaikwad
 
PDF
Getting started with karate dsl
Knoldus Inc.
 
PPTX
Angela Distratis, Luca Pelosi - How to earn a black belt in GraphQL testing ...
Codemotion
 
PPTX
How to earn a black belt in Graphql testing
Luca Pelosi
 
PDF
Flavours - Classic/Technical BDD
David Harrison
 
PPTX
BDD Approach with Karate Framework in Service Tests
kloia
 
PPTX
BRE Automation via karate Framework.pptx
praveenamuthu3
 
PDF
TDC São Paulo 2019 - Trilha DevTest - Karatê DSL - Automatizando testes de AP...
Samuel Lucas
 
PPTX
Testing RESTful web services with REST Assured
Bas Dijkstra
 
PDF
What is Automated API Testing and Why is it Important.pdf
karatelabs1
 
PDF
What is Automated API Testing and Why is it Important
karatelabs1
 
PDF
Rest Assured
Pratham Software (PSI)
 
PPTX
ATAGTR2017 Test the REST
Agile Testing Alliance
 
PDF
РОМАН ЛЮБУНЬ «Automate right, start from API» Lviv QA Day 2019
QADay
 
PPTX
API Testing with Open Source Code and Cucumber
SmartBear
 
PPTX
Automate right start from API
Roman Liubun
 
Karate - MoT Dallas 26-Oct-2017
Peter Thomas
 
apidays LIVE India - Karate for REST and GraphQL test automation by Peter Tho...
apidays
 
Wax on, wax off
Bol.com Techlab
 
API Test Automation using Karate.pdf
Venessa Serrao
 
Karate API Testing-Complete Guidance by Testrig
PritiFGaikwad
 
Getting started with karate dsl
Knoldus Inc.
 
Angela Distratis, Luca Pelosi - How to earn a black belt in GraphQL testing ...
Codemotion
 
How to earn a black belt in Graphql testing
Luca Pelosi
 
Flavours - Classic/Technical BDD
David Harrison
 
BDD Approach with Karate Framework in Service Tests
kloia
 
BRE Automation via karate Framework.pptx
praveenamuthu3
 
TDC São Paulo 2019 - Trilha DevTest - Karatê DSL - Automatizando testes de AP...
Samuel Lucas
 
Testing RESTful web services with REST Assured
Bas Dijkstra
 
What is Automated API Testing and Why is it Important.pdf
karatelabs1
 
What is Automated API Testing and Why is it Important
karatelabs1
 
ATAGTR2017 Test the REST
Agile Testing Alliance
 
РОМАН ЛЮБУНЬ «Automate right, start from API» Lviv QA Day 2019
QADay
 
API Testing with Open Source Code and Cucumber
SmartBear
 
Automate right start from API
Roman Liubun
 
Ad

More from VodqaBLR (20)

PPTX
Consumer-Driven Contract Testing PACT
VodqaBLR
 
PPTX
Taiko presentation
VodqaBLR
 
PPT
Chatbot Testing
VodqaBLR
 
PPTX
Key Note VodQA(Bangalore) 2018
VodqaBLR
 
PDF
Android security testing
VodqaBLR
 
PDF
Advance appium workshop.pptx
VodqaBLR
 
PDF
Blockchain workshop
VodqaBLR
 
PPTX
Testing natural language processing
VodqaBLR
 
PPTX
Drive chrome(headless) with puppeteer
VodqaBLR
 
PPTX
Improve your Chaos IQ
VodqaBLR
 
PPTX
WebDriver Lamda - Next Gen Scalable Test
VodqaBLR
 
PPTX
Testing Tools with AI
VodqaBLR
 
PPTX
Dynamic Security Analysis & Static Security Analysis for Android Apps.
VodqaBLR
 
PDF
Visual testing for Mobile Native Applications
VodqaBLR
 
PPTX
Parallel Sim Test using XCUI
VodqaBLR
 
PPTX
Performance Testing using Taurus
VodqaBLR
 
PPTX
Writing Maintainable Tests
VodqaBLR
 
PPTX
Continuous security testing - sharing responsibility
VodqaBLR
 
PPTX
ABCing docker with environments - workshop
VodqaBLR
 
PDF
Automate Web or Mobile Analytics using TrakMatic
VodqaBLR
 
Consumer-Driven Contract Testing PACT
VodqaBLR
 
Taiko presentation
VodqaBLR
 
Chatbot Testing
VodqaBLR
 
Key Note VodQA(Bangalore) 2018
VodqaBLR
 
Android security testing
VodqaBLR
 
Advance appium workshop.pptx
VodqaBLR
 
Blockchain workshop
VodqaBLR
 
Testing natural language processing
VodqaBLR
 
Drive chrome(headless) with puppeteer
VodqaBLR
 
Improve your Chaos IQ
VodqaBLR
 
WebDriver Lamda - Next Gen Scalable Test
VodqaBLR
 
Testing Tools with AI
VodqaBLR
 
Dynamic Security Analysis & Static Security Analysis for Android Apps.
VodqaBLR
 
Visual testing for Mobile Native Applications
VodqaBLR
 
Parallel Sim Test using XCUI
VodqaBLR
 
Performance Testing using Taurus
VodqaBLR
 
Writing Maintainable Tests
VodqaBLR
 
Continuous security testing - sharing responsibility
VodqaBLR
 
ABCing docker with environments - workshop
VodqaBLR
 
Automate Web or Mobile Analytics using TrakMatic
VodqaBLR
 
Ad

Recently uploaded (20)

PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PDF
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
PPTX
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
PPTX
Tally software_Introduction_Presentation
AditiBansal54083
 
PPTX
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
PPTX
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
PPTX
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
PDF
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PDF
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
PDF
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
PPTX
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
PPTX
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PPTX
Transforming Mining & Engineering Operations with Odoo ERP | Streamline Proje...
SatishKumar2651
 
PDF
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
PPTX
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
Tally software_Introduction_Presentation
AditiBansal54083
 
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
Transforming Mining & Engineering Operations with Odoo ERP | Streamline Proje...
SatishKumar2651
 
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 

Karate - Web-Service API Testing Made Simple

  • 1. Peter Thomas | Architect | Intuit @ptrthomas | @KarateDSL Karate Web Service API Testing Made Simple Bangalore 7th Edition September 9, 2017
  • 2. Intuit Open Source Released 09-Feb-2017 A DSL for writing web-service acceptance tests Built on Cucumber | BDD syntax Karate github.com/intuit/karate
  • 3. 3 Karate in the top 5 OSS API Testing Tools (TechBeacon) Tool Inception Years REST-assured 2010 7 Postman 2012 5 SoapUI 2005 12 JMeter 1998 19 Karate 2017 0.5
  • 4. 4 • Easier to Write • Readable and Concise • Faster Execution • Better Assertions • Integrates into existing CI / CD API-tests with Karate Developer Productivity Maintain- ability Quality
  • 5. 5 Many teams use Java for writing HTTP-API regression tests. Java is not the best language to manipulate JSON / XML. Consequences: • Over-dependence on Java objects for building and validating data-payloads • Object-equality checks done by hand, effort-intensive • So tests end-up taking “short-cuts”, and don’t validate the full response, coverage & quality suffers • Proliferation of helper methods, code bloat & in-house layers • Result: poor Dev Productivity & Maintainability Current State of Web-API Testing • DSL laser-focused on HTTP • JSON and XML are “first-class” citizens of the syntax • Compare deeply-nested payloads in a single step • 3:1 Reduction in Lines of Code • Tests are super-readable and concise • Testing is Easier & actually Fun Karate’s Solve
  • 6. 6 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 Hello World Intuitive DSL for HTTP Payload assertion in one line Second HTTP call using response data JSON is ‘native’ to the syntax
  • 8. 8 Validation examples: JsonPath & RegEx Type Directive Ignore / Exists #ignore | #null | #notnull Primitive Type #boolean | #number | #string Complex Type #array | #object Special #uuid RegEx #regex <regex string> Predicate #? <expression>
  • 11. 11 Comparison with REST-assured http://tinyurl.com/karateraREST-assured Karate Plain Text ❌ (needs compilation) ✅ Parallel Execution ? (partial) ✅ Data Driven Testing ❌ (needs TestNG etc.) ✅ (built-in) Environment Switching ❌ ✅ (built-in) Match full payload in one step ❌ ✅ Update JSON payload / object ❌ ✅ @Test public void lotto_resource_returns_200_with_expected_id_and_winners() { when(). get("/lotto/{id}", 5). then(). statusCode(200). body("lotto.lottoId", equalTo(5), "lotto.winners.winnerId", containsOnly(23, 54)); Scenario: lotto resource returns 200 with expected id and winners Given path ‘lotto’, 5 When method get Then status 200 And match $.lotto.lottoId == 5 And match $.lotto.winners[*].winnerId contains only [23, 54] given(). param("key1", "value1"). param("key2", "value2"). when(). get("/somewhere"). then(). body(containsString("OK")); Given param key1 = ‘value1’ And param key2 = ‘value2’ And path ‘somewhere’ When method get Then response contains ‘OK’ Detailed Comparison
  • 12. 12
  • 13. 13 Metrics – port of an open-source example Reduction of lines of code from 431 à 67 Link: https://github.com/mwinteringham/api-framework/pull/3
  • 14. 14 Components Karate DSL interpreter (Cucumber “Step Definitions”) HTTP Client Abstraction JSON XML JS Engine (Nashorn) Karate ScriptJUnit / Test NG (Runner) Java8JRE HTTP/S calls Cucumber- JVM Data / Assertions match, get, set Reports Apache Jersey
  • 15. 15 The “missing” Cucumber Features that Karate adds Capability Cucumber Karate Step Definitions built-in, no Java code needed ❌ ✅ Re-Use Feature files from other Features ❌ ✅ Dynamic Data-Driven Testing ❌ ✅ Parallel Test Execution and Reporting ❌ ✅ Option to run routines only once per Feature ❌ ✅
  • 17. Demos
  • 19. 19 • Scripts are plain-text, no compilation or IDE required • REST as well as SOAP support • Assert, manipulate, compare and re-use JSON / XML • User defined functions (Java or JavaScript) • Configuration switching (e.g. dev | e2e | pre-prod) • Simple ‘plug and play’ HTTP Header & Auth management • Comprehensive HTTP support: SSL, Proxy, File-Upload • JUnit XML reports compatible with all CI tools • Speed - Parallel Execution of Tests • Mock Servlet – test without starting a container Karate Features BDD Full HTTP CI / CD Ready