Quick Demo
With a summary right in your PRs:
Getting Started
Choose from multiple ways to start testing your API with Schemathesis.
💡 Your API schema can be either a URL or a local path to a JSON/YAML file.
💻 Command-Line Interface
Quick and easy for those who prefer the command line.
Python
- Install via pip:
python -m pip install schemathesis
- Run tests
st run --checks all https://example.schemathesis.io/openapi.json
Docker
- Pull Docker image:
docker pull schemathesis/schemathesis:stable
- Run tests
docker run schemathesis/schemathesis:stable
run --checks all https://example.schemathesis.io/openapi.json
🐍 Python Library
For more control and customization, integrate Schemathesis into your Python codebase.
- Install via pip:
python -m pip install schemathesis
- Add to your tests:
import schemathesis
schema = schemathesis.from_uri("https://example.schemathesis.io/openapi.json")
@schema.parametrize()
def test_api(case):
case.call_and_validate()
💡 See a complete working example project in the /example directory.
How it works
Here’s a simplified overview of how Schemathesis operates:
- Test Generation: Using the API schema to create a test generator that you can fine-tune to your testing requirements.
- Execution and Adaptation: Sending tests to the API and adapting through statistical models and heuristics to optimize subsequent cases based on responses.
- Analysis and Minimization: Checking responses to identify issues. Minimizing means simplifying failing test cases for easier debugging.
- Stateful Testing: Running multistep tests to assess API operations in both isolated and integrated scenarios.
- Reporting: Generating detailed reports with insights and cURL commands for easy issue reproduction.
Research Findings on Open-Source API Testing Tools
Our study, presented at the 44th International Conference on Software Engineering, highlighted Schemathesis’s performance:
Defect Detection: identified a total of 755 bugs in 16 services, finding between 1.4× to 4.5× more defects than the second-best tool in each case.
High Reliability: consistently operates seamlessly on any project, ensuring unwavering stability and reliability.
Explore the full paper at https://ieeexplore.ieee.org/document/9793781 or pre-print at https://arxiv.org/abs/2112.10328
Testimonials
“The world needs modern, spec-based API tests, so we can deliver APIs as-designed. Schemathesis is the right tool for that job.”
“Schemathesis is the only sane way to thoroughly test an API.”
“The tool is absolutely amazing as it can do the negative scenario testing instead of me and much faster! Before I was doing the same tests in Postman client. But it’s much slower and brings maintenance burden.”
“Schemathesis is the best tool for fuzz testing of REST API on the market. We are at Red Hat use it for examining our applications in functional and integrations testing levels.”
“There are different levels of usability and documentation quality among these tools which have been reported, where Schemathesis clearly stands out among the most user-friendly and industry-strength tools.”
Acknowledgements
Schemathesis is built on top of Hypothesis, a powerful property-based testing library for Python.
Additional content
Papers
- Deriving Semantics-Aware Fuzzers from Web API Schemas by @Zac-HD and @Stranger6667
- Description: Explores the automation of API testing through semantics-aware fuzzing. Presented at ICSE 2022.
- Date: 20 Dec 2021
Videos
- API Fuzzing: What it is and why you should use it by José Haro Peralta
- Description: A comprehensive overview and demo of Schemathesis.
- Date: 14 Feb 2023
- Schemathesis tutorial with an accompanying video by Red Hat
- Description: Provides a hands-on tutorial for API testing with Schemathesis.
- Date: 09 Feb 2023
- Effective API schemas testing from DevConf.cz by @Stranger6667
- Description: Talks about using Schemathesis for property-based API schema testing.
- Date: 24 Mar 2021
- API-schema-based testing with schemathesis from EuroPython 2020 by @hultner
- Description: Introduces property-based API testing with Schemathesis.
- Date: 23 Jul 2020