2. CURRENT STATE
Teams still prefer to use Java for API tests.
Manipulation and comparison of large and complex JSON is not easy
using Java.
Dependent on Java Objects for building and validating data-payloads.
Teams still struggle with parallel tests executions as its not provided
inbuilt.
More lines of code, more maintenance.
Non-programmers feels difficulty and hence, separate functional and
automation testing teams in organizations.
3. USING KARATE DSL
Plain-text, super-readable and maintainable API test scripts.
Inbuilt powerful and flexible JSON and XML assertions capability( deep-
equals).
‘smart compare’ of two JSONs or XMLs.
No Java beans or helper code to represent payloads and responses.
Non-programmers can easily contribute in scripting.
Call reusable feature files and functions (Code reusability).
Java-interop so we never "hit a wall" in the framework.
Inbuilt multi-threaded parallel execution and report generation.
Data-driven tests that can use JSON or CSV sources.
Easy plugin with Cucumber-HTML reports.
Reuse same functional API tests as performance tests.
Comprehensive documentation and examples. Check
more at https://github.com/intuit/karate
4. GET REQUEST AND FULL JSON RESPONSE VALIDATION
Get Auth Token
Set API Host URL
Set Request Headers
GET Request
Validate Full JSON Response
5. POST REQUEST AND PARTIAL JSON RESPONSE VALIDATION
Create Single User Create Multiple Users
User Request Payload
POST Request
Validate
Response
for New
User
POST Request
Validate Response for New
User
Test Data
Read Json Request and Set
Request Payload
parameters from Examples
Test Data
9. DELETE REQUEST AND VALIDATION
Call Create User Reusable
Feature
Delete User Request
Validate User is Deleted
10. BEST PRACTICES
First create reusable features which performs GET, POST, PUT and DELETE actions and use
them wherever possible.
Create DBUtils for data retrieval and manipulation like readRow, readRows, updateRows,
deleteRows etc.
Data cleanup before/after every scenario/feature execution.
Use CSV if parameterized Examples test data is large.
Use Assert capabilities of Karate (match == , match contains, match contains deep etc.)
Keep scenarios independent if possible.
Try running scenarios in parallel from the beginning so that scenarios can be fixed to keep
independent.
Differentiate scenario by tags (@smoke, @regression etc) and trigger them accordingly.
11. KEY TAKEAWAYS – KARATE DSL
Teams can directly start API automation using Karate DSL without any base
framework.
Irrespective of programming background, anyone in the product team can
contribute on API automation scripting.
Team becomes more productive as API test scripts becomes more readable and
maintainable.
Automation first approach can be taken as soon as project starts.