Testing with Scenarios
It has become increasingly important to develop highly flexible, performant, and powerful testing roadmaps to catch bugs faster and rapidly iterate. A thorough test suite is essential for:
- Assessing the health of an API
- Providing valuable documentation
- Driving design and implementation
- Managing technical debt
Assessing the Health of an API
APIs require maintenance like any other software. To ensure that your API is functioning properly, a suite of tests should be run periodically to check for weaknesses and errors.
Providing Valuable Documentation & Driving Design
API tests provide insight into how your API behaves under certain scenarios and can drive design if created early enough in the design process. Test/Behavior-driven development (TDD/BDD) encourages you to think about design requirements before writing any code.
Stoplight further promotes this design-first principle by providing Contract Testing; an integration between your tests and your OpenAPI Specification. This allows for immediate validation and verification that your API responses match the “Contract” specified in your OpenAPI spec.
Managing Technical Debt
Microservices and serverless architecture have made it easier than ever to iterate quickly. The downside of rapid development is an increase in bugs and technical debt, making projects harder to manage without a proper testing solution. It is critical to have a comprehensive test suite to allow teams to test the API during development.
Stoplight makes it easy to create a full suite of tests by providing Environment and Context variables, and the ability to reference other scenarios to accelerate test generation and reduce duplication.
- Running Tests In Stoplight
- Running Tests in the Terminal
- Running Tests Triggered by URL
- Using Variables Overview
- $$.env (Environment)
- Sending HTTP Requests
- Contract Testing
- Integrating in Continuous Integration
- Integrating with Jenkins
- Integrating with Travis
- Integrating with CircleCI