KEMBAR78
API Test Automation Using Karate (Anil Kumar Moka) | PPTX
API Test Automation
Using Karate
Current state
• Tests only at presentation layer
• No tests at Business layer/API layer ->
• Potential Defects missed
• DB Vulnerable
• Downstream systems affected
3.5 Hours to complete testing
Why API testing?
Fast and
reliable
Integrated
with every
dev
commit
Catch the
defects
early
Helps us
in No-Fear
releases
REST Methods
HTTP/REST CRUD DB
POST Create INSERT
GET Retrieve SELECT
PUT Update UPDATE
DELETE Delete DELETE
Karate Framework
I want to test web services and
currently use Java
I want to test web services but don’t
know Java/any programming
I develop web services
I am part of a team that
develops/maintains web services
Karate is easier and efficient than
Java
Karate scripts are in plain text
Karate can be used for TDD
Karate increases your velocity and
integrates existing QA and CI/CD
Hello World Example
API testing made simple
Plain text,calling another feature file,JSON payload and order doesn’t matter, Data driven test, Easy
assertions via JSON path
API testing made simple
JSON Array Support
Reading JSON files and manipulating
API testing made simple
Multipart and file uploading
Full JSON response validation in one line
Partial JSON response validation in one line
GraphQL Example with RegEx
Karate vs Rest-assured and Cucumber
Rest-assured Karate
Plain text No Yes
Parallel execution Partial Yes
Data driven testing Not built in Built in
Cucumber enhancements
Cucumber Karate
Built in step definitions No Yes
Re use feature files No Yes
Parallel execution No Yes
Run background only once No Yes
JSON path,RegEx & JavaScript Functions
JSON Schema
Karate vs Rest Assured
Less code = Less maintenance and more efficient
API Testing Values
Pipeline integration
• Can run full
regression with
every code commit
in less than 15 mins
• Enable no fear
release
Improve test
development
efficiency
• Can develop tests
way much faster
compared to UI tests
• Very minimal to 0
maintenance
Can identify API risks
• Identifies defects at
API level which
may not be visible in
GUI
• Prevents DB from
invalid entires
Pipeline with API tests
Reporting
Cucumber Report
Since Karate’s REST test tool is built on
top of Cucumber JVM, you can run your
tests, view reports and leverage any other
Cucumber functionality just as with any
standard java project
Karate key features
Open source
Multi-threaded Parallel
execution support
Integration with Pipeline
jobs
Cucumber based ,
Gherkin Syntax
Re-usable functions and
feature files
Less code = More
efficiency and Less
maintenance
Syntax 'natively'
supports JSON and XML
No CERTS and no
POJO’s required
Easy Assertion; Re-
usable scripts for
complex payloads and
responses
Embedded JavaScript
engine
Integration with Junit &
TestNG
Built-in JSON Schema
Validation support
Demo

API Test Automation Using Karate (Anil Kumar Moka)

  • 1.
  • 2.
    Current state • Testsonly at presentation layer • No tests at Business layer/API layer -> • Potential Defects missed • DB Vulnerable • Downstream systems affected 3.5 Hours to complete testing
  • 3.
    Why API testing? Fastand reliable Integrated with every dev commit Catch the defects early Helps us in No-Fear releases
  • 4.
    REST Methods HTTP/REST CRUDDB POST Create INSERT GET Retrieve SELECT PUT Update UPDATE DELETE Delete DELETE
  • 5.
    Karate Framework I wantto test web services and currently use Java I want to test web services but don’t know Java/any programming I develop web services I am part of a team that develops/maintains web services Karate is easier and efficient than Java Karate scripts are in plain text Karate can be used for TDD Karate increases your velocity and integrates existing QA and CI/CD
  • 7.
  • 8.
    API testing madesimple Plain text,calling another feature file,JSON payload and order doesn’t matter, Data driven test, Easy assertions via JSON path
  • 9.
    API testing madesimple JSON Array Support Reading JSON files and manipulating
  • 10.
    API testing madesimple Multipart and file uploading Full JSON response validation in one line Partial JSON response validation in one line
  • 11.
  • 12.
    Karate vs Rest-assuredand Cucumber Rest-assured Karate Plain text No Yes Parallel execution Partial Yes Data driven testing Not built in Built in Cucumber enhancements Cucumber Karate Built in step definitions No Yes Re use feature files No Yes Parallel execution No Yes Run background only once No Yes
  • 13.
    JSON path,RegEx &JavaScript Functions
  • 14.
  • 15.
    Karate vs RestAssured Less code = Less maintenance and more efficient
  • 16.
    API Testing Values Pipelineintegration • Can run full regression with every code commit in less than 15 mins • Enable no fear release Improve test development efficiency • Can develop tests way much faster compared to UI tests • Very minimal to 0 maintenance Can identify API risks • Identifies defects at API level which may not be visible in GUI • Prevents DB from invalid entires
  • 17.
  • 18.
    Reporting Cucumber Report Since Karate’sREST test tool is built on top of Cucumber JVM, you can run your tests, view reports and leverage any other Cucumber functionality just as with any standard java project
  • 19.
    Karate key features Opensource Multi-threaded Parallel execution support Integration with Pipeline jobs Cucumber based , Gherkin Syntax Re-usable functions and feature files Less code = More efficiency and Less maintenance Syntax 'natively' supports JSON and XML No CERTS and no POJO’s required Easy Assertion; Re- usable scripts for complex payloads and responses Embedded JavaScript engine Integration with Junit & TestNG Built-in JSON Schema Validation support
  • 20.