SlideShare a Scribd company logo
API testing with Open Source
Code libraries and Cucumber
Ole Lensmar – SmartBear
22
Short about “Shift-Left”
• Enterprise testing and QA is moving from late to
early phases in the development life-cycle
– QA -> Dev -> Design
• Tests are being expressed as code instead of using
visual tools (by both QA and Dev)
– Re-use of existing Test assets / scripts for different types of
tests
• Code-driven approach not just for functional testing
– Load/performance testing
– Security testing
– Mocking / Virtualization
33
Testing at API layer vs Unit tests
• API-layer testing = integration testing of
implementing classes/components
• Unit-testing frameworks often used to
”orchestrate”
– Junit / TestNG / Failsafe etc.
• Tests are managed together with implementing
code - using traditional SCM tools
• Tests are executed as part of existing builds
– Test running instance of API vs implementation
44
Code driven approach to API Testing
• HTTP clients
– Apache HTTPClient, OkHttp, Super-agent, etc.
• Generated clients
– Swagger Codegen, WSDL2Java, etc.
• Special purpose libraries
– REST-Assured (Java/Groovy)
– Chakram, (JS)
– ReadyApi4j (Java)
• Cucumber / BDD - many platforms/languages
55
Approach for comparison
• Simple scenario with single and chained REST
requests testing the SwaggerHub integration API
• Framework specific highlights
• All available on GitHub:
https://github.com/olensmar/apidays-apitesting
• All run with maven (“mvn test”) except javascript
sample
66
Apache HTTP-Client
• Widely used java client library for HTTP
• Exposes fluent API for building / executing
requests and reading responses
• Lacks built in support for JSON / XML parsing or
assertions
– Need to do this manually using Jackson/DOM/etc.
77
Generated clients
• Use code-generation tools to generate client from
API description
• Write tests using generated client
– Automate client generation as part of build
• Pros
– API changes can break tests
– Isolates from network layer – tests at functional level
• Cons
– Relies on correctness of client-generator
– Isolates from network layer – tests at functional level
88
REST-Assured
• Fluent Java API for testing REST APIs
• Support both JSON and XML content assertions
– Uses standalone JSONPath and Xpath implementations
• Built in support for multiple authentication types, XSRF,
etc.
• Very customizable at the network/http/marshalling layers
• http://rest-assured.io/
99
ReadyAPI4j
• Fluent Java API
– Leverages the SoapUI Testing engine
– REST, SOAP, Assertions, orchestration, etc.
• Internally compiles tests into “Test Recipes”
(json)
– Can be reused for performance/security testing in
SoapUI
• Execution either locally or remotely
– Local execution for ease of use (open source)
– Remote execution for access control, performance,
reporting, etc. (commercial)
1010
Maven/Java project
ReadyApi4j execution model
API Test
/src/test/java
ReadyApi4j API
Local Engine ReadyAPI
Testserver
API(s) under test
use
use
call
API calls
1111
Challenges with code-driven API testing
• Running against different environments
– Temporary environments (Docker can help)
– Actual environments
• Testing either with or without network
– Network is more realistic – more work to automate
• External dependencies may need to be mocked
– 3rd party APIs, databases, etc.
– For both functional and non-functional testing
• Simulate errors, response times, invalid responses, etc.
Cucumber for API testing
1313
Cucumber – “Executable Specifications”
• Heavily associated with Behavior Driven Development
• “Plain language” verbalization of requirements
– POs, Business Analysts, Developers, Testers, etc.
• For example
Given a user has logged in with valid credentials
When a deposit of 100 USD is made
Then the account balance increases by 100 USD
And the user gets a confirmation message
1414
Scenarios/Features written in “Gherkin”
• Given X
• When Y
• Then Z
• More keywords: And, Feature, Scenario,
Background, etc.
• Packaged into “feature files”
• Cucumber reads feature files and executes
corresponding “StepDefs” or “GlueCode”
1515
Automated Build / Test executions
Cucumber “execution pipeline”
Cucumber
Runner
StepDefs
Component /
System under test
1. Parse
2. Invoke
.feature files
Ant/Maven/Gra
dle/CLI/etc [@tag]
1616
Cucumber StepDefs
• Code that is executed by the cucumber
framework for each statement
• Must be implemented manually to support the
desired vocabulary
• Cucumber Java example -> code!
1717
Cucumber “styles”
• Declarative style
– Domain-specific vocabulary for describing the business
requirements
– Appeals to non-technical users
– High overhead in creation and maintenance
• Imperative style
– Generic vocabulary for describing requirements
– Appeals more to technical users
– Lower maintenance – but “Misses the point”
• Either requires implementation of StepDefs
1818
Declarative API Testing Example
Feature: SwaggerHub REST API
Scenario: Default API Listing
When a request to the API listing is made
Then a list of APIs should be returned within 500ms
Scenario: TestServer API Retrieval
Given an owner named smartbear
And an api named ready-api-testserver
And a version named 1.0.0
When a request to the API listing is made
Then an API definition should be returned within 500ms
1919
Imperative API Testing Example
Feature: Petstore API
Scenario: Find pet by status
Given the API running at http://petstore.swagger.io/v2
When a GET request to /pet/findByStatus is made
And the status parameter is test
And the Accepts header is application/json
Then a 200 response is returned within 50ms
2020
Imperative API Testing Example with Swagger
Feature: Petstore API
operationId gives
path and method
operation parameter
type not neededa defined response
2121
Managing Feature files and StepDefs
• Keep feature files together with source code
and/or in separate repository
• Use tagging feature of Cucumber to selectively
(re)run tests
• Use datasets for parameterization
– Inline or external
• Bundle StepDefs in separate library
– Automate execution
2222
ReadyApi4j - Cucumber for APIs
• Out-of-the box generic vocabulary for REST API Testing -
integrated Swagger support
• Extensible – built on Cucumber for Java
– Open-source on GitHub
– https://github.com/readyapi/testserver-cucumber
• Packaged as library or Docker image
– https://hub.docker.com/r/smartbear/cucumber4apis
• Uses ReadyApi4j as execution engine (either local or
remote)
2323
That’s it! – Questions?
• @olensmar
• https://github.com/olensmar/apidays-apitesting
• https://hc.apache.org
• http://rest-assured.io/
• http://dareid.github.io/chakram/
• http://frisbyjs.com/
• https://github.com/SmartBear/readyapi4j
• https://cucumber.io/
• https://github.com/readyapi/testserver-cucumber
• https://hub.docker.com/r/smartbear/cucumber4apis

More Related Content

What's hot (20)

PPTX
API Testing for everyone.pptx
Pricilla Bilavendran
 
PPTX
Testing microservices with rest assured
Kushan Shalindra Amarasiri - Technical QE Specialist
 
PPTX
RESTful API Testing using Postman, Newman, and Jenkins
QASymphony
 
PPSX
API Test Automation
SQALab
 
PPTX
Belajar Postman test runner
Fachrul Choliluddin
 
PPTX
Cypress Testing.pptx
JasmeenShrestha
 
PPTX
Postman. From simple API test to end to end scenario
HYS Enterprise
 
PPTX
Test Design and Automation for REST API
Ivan Katunou
 
PPTX
Introduction to Bdd and cucumber
Nibu Baby
 
PPTX
API Test Automation Using Karate (Anil Kumar Moka)
Peter Thomas
 
PPTX
Api Testing
Vishwanath KC
 
PPT
Agile Testing Process
Intetics
 
PDF
Rest API Automation with REST Assured
TO THE NEW Pvt. Ltd.
 
PPTX
Test Automation and Selenium
Karapet Sarkisyan
 
PDF
Karate - powerful and simple framework for REST API automation testing
Roman Liubun
 
PPTX
Postman Introduction
Rahul Agarwal
 
PPTX
B4USolution_API-Testing
b4usolution .
 
PPTX
Karate DSL
anil borse
 
PPTX
API Testing Using REST Assured with TestNG
Siddharth Sharma
 
PDF
Gradle - the Enterprise Automation Tool
Izzet Mustafaiev
 
API Testing for everyone.pptx
Pricilla Bilavendran
 
Testing microservices with rest assured
Kushan Shalindra Amarasiri - Technical QE Specialist
 
RESTful API Testing using Postman, Newman, and Jenkins
QASymphony
 
API Test Automation
SQALab
 
Belajar Postman test runner
Fachrul Choliluddin
 
Cypress Testing.pptx
JasmeenShrestha
 
Postman. From simple API test to end to end scenario
HYS Enterprise
 
Test Design and Automation for REST API
Ivan Katunou
 
Introduction to Bdd and cucumber
Nibu Baby
 
API Test Automation Using Karate (Anil Kumar Moka)
Peter Thomas
 
Api Testing
Vishwanath KC
 
Agile Testing Process
Intetics
 
Rest API Automation with REST Assured
TO THE NEW Pvt. Ltd.
 
Test Automation and Selenium
Karapet Sarkisyan
 
Karate - powerful and simple framework for REST API automation testing
Roman Liubun
 
Postman Introduction
Rahul Agarwal
 
B4USolution_API-Testing
b4usolution .
 
Karate DSL
anil borse
 
API Testing Using REST Assured with TestNG
Siddharth Sharma
 
Gradle - the Enterprise Automation Tool
Izzet Mustafaiev
 

Similar to API Testing with Open Source Code and Cucumber (20)

PDF
Top 11 API testing tools for 2022
Aparna Sharma
 
PDF
Top 11 api testing tools for 2022
Aparna Sharma
 
PDF
End to End Testing: Bug Squashing for API Developers
Apigee | Google Cloud
 
DOCX
Diversified AT Framework - Initial Version
Yu Tao Zhang
 
PDF
Next-Level API Automation Testing Techniques – Part 2
digitaljignect
 
PPTX
Testing API's: Tools & Tips & Tricks (Oh My!)
Ford Prior
 
PDF
Next-Level API Automation Testing Techniques – Part 1
digitaljignect
 
PDF
Top 20 Automated API testing Tools for Effective Software Testing.pdf
kalichargn70th171
 
PDF
QA Meetup at Signavio (Berlin, 06.06.19)
Anesthezia
 
PDF
5 levels of api test automation
ShekharRamphal
 
PDF
Top 20 Automated API testing Tools for Effective Software Testing.pdf
flufftailshop
 
PDF
Automated acceptance test
Bryan Liu
 
PPTX
API testing - Japura.pptx
TharindaLiyanage1
 
PDF
Deep dive into SoapUI
Andrey Oleynik
 
PPTX
Tools and techniques for APIs
Jason Harmon
 
PPTX
Asynchronous API Testing: Trends, Tools & More | Calidad Infotech
Calidad Infotech
 
PPTX
A basic introduction to API Testing & its importance.
Prashantsingh911569
 
PPTX
BDD for APIs
Jason Harmon
 
PDF
How to Automate API Testing
Bruno Pedro
 
PPTX
Automate test, tools, advantages, and disadvantages
Majid Hosseini
 
Top 11 API testing tools for 2022
Aparna Sharma
 
Top 11 api testing tools for 2022
Aparna Sharma
 
End to End Testing: Bug Squashing for API Developers
Apigee | Google Cloud
 
Diversified AT Framework - Initial Version
Yu Tao Zhang
 
Next-Level API Automation Testing Techniques – Part 2
digitaljignect
 
Testing API's: Tools & Tips & Tricks (Oh My!)
Ford Prior
 
Next-Level API Automation Testing Techniques – Part 1
digitaljignect
 
Top 20 Automated API testing Tools for Effective Software Testing.pdf
kalichargn70th171
 
QA Meetup at Signavio (Berlin, 06.06.19)
Anesthezia
 
5 levels of api test automation
ShekharRamphal
 
Top 20 Automated API testing Tools for Effective Software Testing.pdf
flufftailshop
 
Automated acceptance test
Bryan Liu
 
API testing - Japura.pptx
TharindaLiyanage1
 
Deep dive into SoapUI
Andrey Oleynik
 
Tools and techniques for APIs
Jason Harmon
 
Asynchronous API Testing: Trends, Tools & More | Calidad Infotech
Calidad Infotech
 
A basic introduction to API Testing & its importance.
Prashantsingh911569
 
BDD for APIs
Jason Harmon
 
How to Automate API Testing
Bruno Pedro
 
Automate test, tools, advantages, and disadvantages
Majid Hosseini
 
Ad

More from SmartBear (20)

PPTX
Enforcing Your Organization's API Design Standards with SwaggerHub
SmartBear
 
PPTX
Introducing OpenAPI Version 3.1
SmartBear
 
PPTX
IATA Open Air: How API Standardization Enables Innovation in the Airline Indu...
SmartBear
 
PPTX
The State of API 2020 Webinar – Exploring Trends, Tools & Takeaways to Drive ...
SmartBear
 
PPTX
How LISI Automotive Accelerated Application Delivery with SwaggerHub
SmartBear
 
PPTX
Standardising APIs: Powering the Platform Economy in Financial Services
SmartBear
 
PPTX
Getting Started with API Standardization in SwaggerHub
SmartBear
 
PPTX
Adopting a Design-First Approach to API Development with SwaggerHub
SmartBear
 
PPTX
Standardizing APIs Across Your Organization with Swagger and OAS | A SmartBea...
SmartBear
 
PPTX
Effective API Lifecycle Management
SmartBear
 
PDF
The API Lifecycle Series: Exploring Design-First and Code-First Approaches to...
SmartBear
 
PDF
The API Lifecycle Series: Evolving API Development and Testing from Open Sour...
SmartBear
 
PPTX
Artificial intelligence for faster and smarter software testing - Galway Mee...
SmartBear
 
PDF
Successfully Implementing BDD in an Agile World
SmartBear
 
PPTX
The Best Kept Secrets of Code Review | SmartBear Webinar
SmartBear
 
PPTX
How Capital One Scaled API Design to Deliver New Products Faster
SmartBear
 
PPTX
Testing Without a GUI Using TestComplete
SmartBear
 
PPTX
Hidden Treasure - TestComplete Script Extensions
SmartBear
 
PDF
How Bdd Can Save Agile
SmartBear
 
PPTX
API Automation and TDD to Implement Master Data Survivorship Rules
SmartBear
 
Enforcing Your Organization's API Design Standards with SwaggerHub
SmartBear
 
Introducing OpenAPI Version 3.1
SmartBear
 
IATA Open Air: How API Standardization Enables Innovation in the Airline Indu...
SmartBear
 
The State of API 2020 Webinar – Exploring Trends, Tools & Takeaways to Drive ...
SmartBear
 
How LISI Automotive Accelerated Application Delivery with SwaggerHub
SmartBear
 
Standardising APIs: Powering the Platform Economy in Financial Services
SmartBear
 
Getting Started with API Standardization in SwaggerHub
SmartBear
 
Adopting a Design-First Approach to API Development with SwaggerHub
SmartBear
 
Standardizing APIs Across Your Organization with Swagger and OAS | A SmartBea...
SmartBear
 
Effective API Lifecycle Management
SmartBear
 
The API Lifecycle Series: Exploring Design-First and Code-First Approaches to...
SmartBear
 
The API Lifecycle Series: Evolving API Development and Testing from Open Sour...
SmartBear
 
Artificial intelligence for faster and smarter software testing - Galway Mee...
SmartBear
 
Successfully Implementing BDD in an Agile World
SmartBear
 
The Best Kept Secrets of Code Review | SmartBear Webinar
SmartBear
 
How Capital One Scaled API Design to Deliver New Products Faster
SmartBear
 
Testing Without a GUI Using TestComplete
SmartBear
 
Hidden Treasure - TestComplete Script Extensions
SmartBear
 
How Bdd Can Save Agile
SmartBear
 
API Automation and TDD to Implement Master Data Survivorship Rules
SmartBear
 
Ad

Recently uploaded (20)

PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 

API Testing with Open Source Code and Cucumber

  • 1. API testing with Open Source Code libraries and Cucumber Ole Lensmar – SmartBear
  • 2. 22 Short about “Shift-Left” • Enterprise testing and QA is moving from late to early phases in the development life-cycle – QA -> Dev -> Design • Tests are being expressed as code instead of using visual tools (by both QA and Dev) – Re-use of existing Test assets / scripts for different types of tests • Code-driven approach not just for functional testing – Load/performance testing – Security testing – Mocking / Virtualization
  • 3. 33 Testing at API layer vs Unit tests • API-layer testing = integration testing of implementing classes/components • Unit-testing frameworks often used to ”orchestrate” – Junit / TestNG / Failsafe etc. • Tests are managed together with implementing code - using traditional SCM tools • Tests are executed as part of existing builds – Test running instance of API vs implementation
  • 4. 44 Code driven approach to API Testing • HTTP clients – Apache HTTPClient, OkHttp, Super-agent, etc. • Generated clients – Swagger Codegen, WSDL2Java, etc. • Special purpose libraries – REST-Assured (Java/Groovy) – Chakram, (JS) – ReadyApi4j (Java) • Cucumber / BDD - many platforms/languages
  • 5. 55 Approach for comparison • Simple scenario with single and chained REST requests testing the SwaggerHub integration API • Framework specific highlights • All available on GitHub: https://github.com/olensmar/apidays-apitesting • All run with maven (“mvn test”) except javascript sample
  • 6. 66 Apache HTTP-Client • Widely used java client library for HTTP • Exposes fluent API for building / executing requests and reading responses • Lacks built in support for JSON / XML parsing or assertions – Need to do this manually using Jackson/DOM/etc.
  • 7. 77 Generated clients • Use code-generation tools to generate client from API description • Write tests using generated client – Automate client generation as part of build • Pros – API changes can break tests – Isolates from network layer – tests at functional level • Cons – Relies on correctness of client-generator – Isolates from network layer – tests at functional level
  • 8. 88 REST-Assured • Fluent Java API for testing REST APIs • Support both JSON and XML content assertions – Uses standalone JSONPath and Xpath implementations • Built in support for multiple authentication types, XSRF, etc. • Very customizable at the network/http/marshalling layers • http://rest-assured.io/
  • 9. 99 ReadyAPI4j • Fluent Java API – Leverages the SoapUI Testing engine – REST, SOAP, Assertions, orchestration, etc. • Internally compiles tests into “Test Recipes” (json) – Can be reused for performance/security testing in SoapUI • Execution either locally or remotely – Local execution for ease of use (open source) – Remote execution for access control, performance, reporting, etc. (commercial)
  • 10. 1010 Maven/Java project ReadyApi4j execution model API Test /src/test/java ReadyApi4j API Local Engine ReadyAPI Testserver API(s) under test use use call API calls
  • 11. 1111 Challenges with code-driven API testing • Running against different environments – Temporary environments (Docker can help) – Actual environments • Testing either with or without network – Network is more realistic – more work to automate • External dependencies may need to be mocked – 3rd party APIs, databases, etc. – For both functional and non-functional testing • Simulate errors, response times, invalid responses, etc.
  • 12. Cucumber for API testing
  • 13. 1313 Cucumber – “Executable Specifications” • Heavily associated with Behavior Driven Development • “Plain language” verbalization of requirements – POs, Business Analysts, Developers, Testers, etc. • For example Given a user has logged in with valid credentials When a deposit of 100 USD is made Then the account balance increases by 100 USD And the user gets a confirmation message
  • 14. 1414 Scenarios/Features written in “Gherkin” • Given X • When Y • Then Z • More keywords: And, Feature, Scenario, Background, etc. • Packaged into “feature files” • Cucumber reads feature files and executes corresponding “StepDefs” or “GlueCode”
  • 15. 1515 Automated Build / Test executions Cucumber “execution pipeline” Cucumber Runner StepDefs Component / System under test 1. Parse 2. Invoke .feature files Ant/Maven/Gra dle/CLI/etc [@tag]
  • 16. 1616 Cucumber StepDefs • Code that is executed by the cucumber framework for each statement • Must be implemented manually to support the desired vocabulary • Cucumber Java example -> code!
  • 17. 1717 Cucumber “styles” • Declarative style – Domain-specific vocabulary for describing the business requirements – Appeals to non-technical users – High overhead in creation and maintenance • Imperative style – Generic vocabulary for describing requirements – Appeals more to technical users – Lower maintenance – but “Misses the point” • Either requires implementation of StepDefs
  • 18. 1818 Declarative API Testing Example Feature: SwaggerHub REST API Scenario: Default API Listing When a request to the API listing is made Then a list of APIs should be returned within 500ms Scenario: TestServer API Retrieval Given an owner named smartbear And an api named ready-api-testserver And a version named 1.0.0 When a request to the API listing is made Then an API definition should be returned within 500ms
  • 19. 1919 Imperative API Testing Example Feature: Petstore API Scenario: Find pet by status Given the API running at http://petstore.swagger.io/v2 When a GET request to /pet/findByStatus is made And the status parameter is test And the Accepts header is application/json Then a 200 response is returned within 50ms
  • 20. 2020 Imperative API Testing Example with Swagger Feature: Petstore API operationId gives path and method operation parameter type not neededa defined response
  • 21. 2121 Managing Feature files and StepDefs • Keep feature files together with source code and/or in separate repository • Use tagging feature of Cucumber to selectively (re)run tests • Use datasets for parameterization – Inline or external • Bundle StepDefs in separate library – Automate execution
  • 22. 2222 ReadyApi4j - Cucumber for APIs • Out-of-the box generic vocabulary for REST API Testing - integrated Swagger support • Extensible – built on Cucumber for Java – Open-source on GitHub – https://github.com/readyapi/testserver-cucumber • Packaged as library or Docker image – https://hub.docker.com/r/smartbear/cucumber4apis • Uses ReadyApi4j as execution engine (either local or remote)
  • 23. 2323 That’s it! – Questions? • @olensmar • https://github.com/olensmar/apidays-apitesting • https://hc.apache.org • http://rest-assured.io/ • http://dareid.github.io/chakram/ • http://frisbyjs.com/ • https://github.com/SmartBear/readyapi4j • https://cucumber.io/ • https://github.com/readyapi/testserver-cucumber • https://hub.docker.com/r/smartbear/cucumber4apis