SlideShare a Scribd company logo
1 of 22
Download to read offline
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

Testing RESTful web services with REST Assured
Testing RESTful web services with REST AssuredTesting RESTful web services with REST Assured
Testing RESTful web services with REST AssuredBas Dijkstra
 
Test Design and Automation for REST API
Test Design and Automation for REST APITest Design and Automation for REST API
Test Design and Automation for REST APIIvan Katunou
 
How to earn a black belt in Graphql testing
How to earn a black belt in Graphql testingHow to earn a black belt in Graphql testing
How to earn a black belt in Graphql testingLuca Pelosi
 
An Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
An Introduction to JUnit 5 and how to use it with Spring boot tests and MockitoAn Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
An Introduction to JUnit 5 and how to use it with Spring boot tests and Mockitoshaunthomas999
 
Criando uma arquitetura para seus testes de API com RestAssured
Criando uma arquitetura para seus testes de API com RestAssuredCriando uma arquitetura para seus testes de API com RestAssured
Criando uma arquitetura para seus testes de API com RestAssuredElias Nogueira
 
API Testing with Open Source Code and Cucumber
API Testing with Open Source Code and CucumberAPI Testing with Open Source Code and Cucumber
API Testing with Open Source Code and CucumberSmartBear
 
An Introduction To Automated API Testing
An Introduction To Automated API TestingAn Introduction To Automated API Testing
An Introduction To Automated API TestingSauce Labs
 
API Testing Using REST Assured with TestNG
API Testing Using REST Assured with TestNGAPI Testing Using REST Assured with TestNG
API Testing Using REST Assured with TestNGSiddharth Sharma
 
Test your microservices with REST-Assured
Test your microservices with REST-AssuredTest your microservices with REST-Assured
Test your microservices with REST-AssuredMichel Schudel
 
How to go about testing in React?
How to go about testing in React? How to go about testing in React?
How to go about testing in React? Lisa Gagarina
 
REST API testing with SpecFlow
REST API testing with SpecFlowREST API testing with SpecFlow
REST API testing with SpecFlowAiste Stikliute
 
Test Automation Framework using Cucumber BDD overview (part 1)
Test Automation Framework using Cucumber BDD overview (part 1)Test Automation Framework using Cucumber BDD overview (part 1)
Test Automation Framework using Cucumber BDD overview (part 1)Mindfire Solutions
 
Automação e virtualização de serviços
Automação e virtualização de serviçosAutomação e virtualização de serviços
Automação e virtualização de serviçosElias Nogueira
 
API Automation Testing Using RestAssured+Cucumber
API Automation Testing Using RestAssured+CucumberAPI Automation Testing Using RestAssured+Cucumber
API Automation Testing Using RestAssured+CucumberKnoldus Inc.
 
Code Review Best Practices
Code Review Best PracticesCode Review Best Practices
Code Review Best PracticesTrisha Gee
 
Test in Rest. API testing with the help of Rest Assured.
Test in Rest. API testing with the help of  Rest Assured.Test in Rest. API testing with the help of  Rest Assured.
Test in Rest. API testing with the help of Rest Assured.Artem Korchevyi
 
Painless JavaScript Testing with Jest
Painless JavaScript Testing with JestPainless JavaScript Testing with Jest
Painless JavaScript Testing with JestMichał Pierzchała
 
The Many Ways to Test Your React App
The Many Ways to Test Your React AppThe Many Ways to Test Your React App
The Many Ways to Test Your React AppAll Things Open
 

What's hot (20)

Testing RESTful web services with REST Assured
Testing RESTful web services with REST AssuredTesting RESTful web services with REST Assured
Testing RESTful web services with REST Assured
 
Test Design and Automation for REST API
Test Design and Automation for REST APITest Design and Automation for REST API
Test Design and Automation for REST API
 
How to earn a black belt in Graphql testing
How to earn a black belt in Graphql testingHow to earn a black belt in Graphql testing
How to earn a black belt in Graphql testing
 
An Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
An Introduction to JUnit 5 and how to use it with Spring boot tests and MockitoAn Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
An Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
 
Criando uma arquitetura para seus testes de API com RestAssured
Criando uma arquitetura para seus testes de API com RestAssuredCriando uma arquitetura para seus testes de API com RestAssured
Criando uma arquitetura para seus testes de API com RestAssured
 
API Testing with Open Source Code and Cucumber
API Testing with Open Source Code and CucumberAPI Testing with Open Source Code and Cucumber
API Testing with Open Source Code and Cucumber
 
An Introduction To Automated API Testing
An Introduction To Automated API TestingAn Introduction To Automated API Testing
An Introduction To Automated API Testing
 
API Testing Using REST Assured with TestNG
API Testing Using REST Assured with TestNGAPI Testing Using REST Assured with TestNG
API Testing Using REST Assured with TestNG
 
Test your microservices with REST-Assured
Test your microservices with REST-AssuredTest your microservices with REST-Assured
Test your microservices with REST-Assured
 
How to go about testing in React?
How to go about testing in React? How to go about testing in React?
How to go about testing in React?
 
Gherkin /BDD intro
Gherkin /BDD introGherkin /BDD intro
Gherkin /BDD intro
 
REST API testing with SpecFlow
REST API testing with SpecFlowREST API testing with SpecFlow
REST API testing with SpecFlow
 
Test Automation Framework using Cucumber BDD overview (part 1)
Test Automation Framework using Cucumber BDD overview (part 1)Test Automation Framework using Cucumber BDD overview (part 1)
Test Automation Framework using Cucumber BDD overview (part 1)
 
Arquitetura Node com NestJS
Arquitetura Node com NestJSArquitetura Node com NestJS
Arquitetura Node com NestJS
 
Automação e virtualização de serviços
Automação e virtualização de serviçosAutomação e virtualização de serviços
Automação e virtualização de serviços
 
API Automation Testing Using RestAssured+Cucumber
API Automation Testing Using RestAssured+CucumberAPI Automation Testing Using RestAssured+Cucumber
API Automation Testing Using RestAssured+Cucumber
 
Code Review Best Practices
Code Review Best PracticesCode Review Best Practices
Code Review Best Practices
 
Test in Rest. API testing with the help of Rest Assured.
Test in Rest. API testing with the help of  Rest Assured.Test in Rest. API testing with the help of  Rest Assured.
Test in Rest. API testing with the help of Rest Assured.
 
Painless JavaScript Testing with Jest
Painless JavaScript Testing with JestPainless JavaScript Testing with Jest
Painless JavaScript Testing with Jest
 
The Many Ways to Test Your React App
The Many Ways to Test Your React AppThe Many Ways to Test Your React App
The Many Ways to Test Your React App
 

Similar to Karate - Web-Service API Testing Made Simple

Karate - MoT Dallas 26-Oct-2017
Karate - MoT Dallas 26-Oct-2017Karate - MoT Dallas 26-Oct-2017
Karate - MoT Dallas 26-Oct-2017Peter Thomas
 
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017Ortus Solutions, Corp
 
Testing for fun in production Into The Box 2018
Testing for fun in production Into The Box 2018Testing for fun in production Into The Box 2018
Testing for fun in production Into The Box 2018Ortus Solutions, Corp
 
apidays LIVE India - Karate for REST and GraphQL test automation by Peter Tho...
apidays LIVE India - Karate for REST and GraphQL test automation by Peter Tho...apidays LIVE India - Karate for REST and GraphQL test automation by Peter Tho...
apidays LIVE India - Karate for REST and GraphQL test automation by Peter Tho...apidays
 
Top100summit 谷歌-scott-improve your automated web application testing
Top100summit  谷歌-scott-improve your automated web application testingTop100summit  谷歌-scott-improve your automated web application testing
Top100summit 谷歌-scott-improve your automated web application testingdrewz lin
 
ERRest - Designing a good REST service
ERRest - Designing a good REST serviceERRest - Designing a good REST service
ERRest - Designing a good REST serviceWO Community
 
Intro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran MizrahiIntro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran MizrahiRan Mizrahi
 
Quick tour to front end unit testing using jasmine
Quick tour to front end unit testing using jasmineQuick tour to front end unit testing using jasmine
Quick tour to front end unit testing using jasmineGil Fink
 
Testing JavaScript with Jasmine in Rails Applications
Testing JavaScript with Jasmine in Rails Applications Testing JavaScript with Jasmine in Rails Applications
Testing JavaScript with Jasmine in Rails Applications Hector Correa
 
BDD API Tests with Gherkin and Behat
BDD API Tests with Gherkin and BehatBDD API Tests with Gherkin and Behat
BDD API Tests with Gherkin and BehatMark Niebergall
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenerytoddbr
 
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
3 Ways to test your ColdFusion API - 2017 Adobe CF SummitOrtus Solutions, Corp
 
Timings API: Performance Assertion during the functional testing
 Timings API: Performance Assertion during the functional testing Timings API: Performance Assertion during the functional testing
Timings API: Performance Assertion during the functional testingPetrosPlakogiannis
 
Java script unit testing
Java script unit testingJava script unit testing
Java script unit testingMats Bryntse
 
Testing ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NETTesting ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NETBen Hall
 
Automated acceptance test
Automated acceptance testAutomated acceptance test
Automated acceptance testBryan Liu
 
Developing node-mdb: a Node.js - based clone of SimpleDB
Developing node-mdb: a Node.js - based clone of SimpleDBDeveloping node-mdb: a Node.js - based clone of SimpleDB
Developing node-mdb: a Node.js - based clone of SimpleDBRob Tweed
 

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

Karate - MoT Dallas 26-Oct-2017
Karate - MoT Dallas 26-Oct-2017Karate - MoT Dallas 26-Oct-2017
Karate - MoT Dallas 26-Oct-2017
 
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017
 
Testing for fun in production Into The Box 2018
Testing for fun in production Into The Box 2018Testing for fun in production Into The Box 2018
Testing for fun in production Into The Box 2018
 
apidays LIVE India - Karate for REST and GraphQL test automation by Peter Tho...
apidays LIVE India - Karate for REST and GraphQL test automation by Peter Tho...apidays LIVE India - Karate for REST and GraphQL test automation by Peter Tho...
apidays LIVE India - Karate for REST and GraphQL test automation by Peter Tho...
 
Top100summit 谷歌-scott-improve your automated web application testing
Top100summit  谷歌-scott-improve your automated web application testingTop100summit  谷歌-scott-improve your automated web application testing
Top100summit 谷歌-scott-improve your automated web application testing
 
ERRest - Designing a good REST service
ERRest - Designing a good REST serviceERRest - Designing a good REST service
ERRest - Designing a good REST service
 
BDD in iOS with Cedar
BDD in iOS with CedarBDD in iOS with Cedar
BDD in iOS with Cedar
 
Intro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran MizrahiIntro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran Mizrahi
 
Quick tour to front end unit testing using jasmine
Quick tour to front end unit testing using jasmineQuick tour to front end unit testing using jasmine
Quick tour to front end unit testing using jasmine
 
Testing JavaScript with Jasmine in Rails Applications
Testing JavaScript with Jasmine in Rails Applications Testing JavaScript with Jasmine in Rails Applications
Testing JavaScript with Jasmine in Rails Applications
 
BDD API Tests with Gherkin and Behat
BDD API Tests with Gherkin and BehatBDD API Tests with Gherkin and Behat
BDD API Tests with Gherkin and Behat
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenery
 
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
 
Timings API: Performance Assertion during the functional testing
 Timings API: Performance Assertion during the functional testing Timings API: Performance Assertion during the functional testing
Timings API: Performance Assertion during the functional testing
 
Java script unit testing
Java script unit testingJava script unit testing
Java script unit testing
 
Testing ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NETTesting ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NET
 
Automated acceptance test
Automated acceptance testAutomated acceptance test
Automated acceptance test
 
Developing node-mdb: a Node.js - based clone of SimpleDB
Developing node-mdb: a Node.js - based clone of SimpleDBDeveloping node-mdb: a Node.js - based clone of SimpleDB
Developing node-mdb: a Node.js - based clone of SimpleDB
 
Getting Started With Testing
Getting Started With TestingGetting Started With Testing
Getting Started With Testing
 
Junit_.pptx
Junit_.pptxJunit_.pptx
Junit_.pptx
 

More from VodqaBLR

Consumer-Driven Contract Testing PACT
Consumer-Driven Contract Testing PACTConsumer-Driven Contract Testing PACT
Consumer-Driven Contract Testing PACTVodqaBLR
 
Taiko presentation
Taiko presentationTaiko presentation
Taiko presentationVodqaBLR
 
Chatbot Testing
Chatbot TestingChatbot Testing
Chatbot TestingVodqaBLR
 
Key Note VodQA(Bangalore) 2018
Key Note VodQA(Bangalore) 2018Key Note VodQA(Bangalore) 2018
Key Note VodQA(Bangalore) 2018VodqaBLR
 
Android security testing
Android security testingAndroid security testing
Android security testingVodqaBLR
 
Advance appium workshop.pptx
Advance appium workshop.pptxAdvance appium workshop.pptx
Advance appium workshop.pptxVodqaBLR
 
Blockchain workshop
Blockchain workshopBlockchain workshop
Blockchain workshopVodqaBLR
 
Testing natural language processing
Testing natural language processingTesting natural language processing
Testing natural language processingVodqaBLR
 
Drive chrome(headless) with puppeteer
Drive chrome(headless) with puppeteerDrive chrome(headless) with puppeteer
Drive chrome(headless) with puppeteerVodqaBLR
 
Improve your Chaos IQ
Improve your Chaos IQImprove your Chaos IQ
Improve your Chaos IQVodqaBLR
 
WebDriver Lamda - Next Gen Scalable Test
WebDriver Lamda - Next Gen Scalable TestWebDriver Lamda - Next Gen Scalable Test
WebDriver Lamda - Next Gen Scalable TestVodqaBLR
 
Testing Tools with AI
Testing Tools with AITesting Tools with AI
Testing Tools with AIVodqaBLR
 
Dynamic Security Analysis & Static Security Analysis for Android Apps.
Dynamic Security Analysis & Static Security Analysis for Android Apps.Dynamic Security Analysis & Static Security Analysis for Android Apps.
Dynamic Security Analysis & Static Security Analysis for Android Apps.VodqaBLR
 
Visual testing for Mobile Native Applications
Visual testing for Mobile Native ApplicationsVisual testing for Mobile Native Applications
Visual testing for Mobile Native ApplicationsVodqaBLR
 
Parallel Sim Test using XCUI
Parallel Sim Test using XCUI Parallel Sim Test using XCUI
Parallel Sim Test using XCUI VodqaBLR
 
Performance Testing using Taurus
Performance Testing using TaurusPerformance Testing using Taurus
Performance Testing using TaurusVodqaBLR
 
Writing Maintainable Tests
Writing Maintainable TestsWriting Maintainable Tests
Writing Maintainable TestsVodqaBLR
 
Continuous security testing - sharing responsibility
Continuous security testing - sharing responsibilityContinuous security testing - sharing responsibility
Continuous security testing - sharing responsibilityVodqaBLR
 
ABCing docker with environments - workshop
ABCing docker with environments - workshopABCing docker with environments - workshop
ABCing docker with environments - workshopVodqaBLR
 
Automate Web or Mobile Analytics using TrakMatic
Automate Web or Mobile Analytics using TrakMaticAutomate Web or Mobile Analytics using TrakMatic
Automate Web or Mobile Analytics using TrakMaticVodqaBLR
 

More from VodqaBLR (20)

Consumer-Driven Contract Testing PACT
Consumer-Driven Contract Testing PACTConsumer-Driven Contract Testing PACT
Consumer-Driven Contract Testing PACT
 
Taiko presentation
Taiko presentationTaiko presentation
Taiko presentation
 
Chatbot Testing
Chatbot TestingChatbot Testing
Chatbot Testing
 
Key Note VodQA(Bangalore) 2018
Key Note VodQA(Bangalore) 2018Key Note VodQA(Bangalore) 2018
Key Note VodQA(Bangalore) 2018
 
Android security testing
Android security testingAndroid security testing
Android security testing
 
Advance appium workshop.pptx
Advance appium workshop.pptxAdvance appium workshop.pptx
Advance appium workshop.pptx
 
Blockchain workshop
Blockchain workshopBlockchain workshop
Blockchain workshop
 
Testing natural language processing
Testing natural language processingTesting natural language processing
Testing natural language processing
 
Drive chrome(headless) with puppeteer
Drive chrome(headless) with puppeteerDrive chrome(headless) with puppeteer
Drive chrome(headless) with puppeteer
 
Improve your Chaos IQ
Improve your Chaos IQImprove your Chaos IQ
Improve your Chaos IQ
 
WebDriver Lamda - Next Gen Scalable Test
WebDriver Lamda - Next Gen Scalable TestWebDriver Lamda - Next Gen Scalable Test
WebDriver Lamda - Next Gen Scalable Test
 
Testing Tools with AI
Testing Tools with AITesting Tools with AI
Testing Tools with AI
 
Dynamic Security Analysis & Static Security Analysis for Android Apps.
Dynamic Security Analysis & Static Security Analysis for Android Apps.Dynamic Security Analysis & Static Security Analysis for Android Apps.
Dynamic Security Analysis & Static Security Analysis for Android Apps.
 
Visual testing for Mobile Native Applications
Visual testing for Mobile Native ApplicationsVisual testing for Mobile Native Applications
Visual testing for Mobile Native Applications
 
Parallel Sim Test using XCUI
Parallel Sim Test using XCUI Parallel Sim Test using XCUI
Parallel Sim Test using XCUI
 
Performance Testing using Taurus
Performance Testing using TaurusPerformance Testing using Taurus
Performance Testing using Taurus
 
Writing Maintainable Tests
Writing Maintainable TestsWriting Maintainable Tests
Writing Maintainable Tests
 
Continuous security testing - sharing responsibility
Continuous security testing - sharing responsibilityContinuous security testing - sharing responsibility
Continuous security testing - sharing responsibility
 
ABCing docker with environments - workshop
ABCing docker with environments - workshopABCing docker with environments - workshop
ABCing docker with environments - workshop
 
Automate Web or Mobile Analytics using TrakMatic
Automate Web or Mobile Analytics using TrakMaticAutomate Web or Mobile Analytics using TrakMatic
Automate Web or Mobile Analytics using TrakMatic
 

Recently uploaded

BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 

Recently uploaded (20)

BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 

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