This sample project illustrates the implementation of contract-driven development and contract testing within a Flask (Python) application. In this context, Specmatic is utilized to function as a client, making calls to API service according to its OpenAPI specification to validate its functionality.
Here is the API's contract/open api spec
- Flask
- Specmatic
- PyTest
- Coverage
- Install Python 3.12
- Install JRE 17 or later.
-
Create a virtual environment named ".venv" by executing the following command in the terminal from the project's root directory
python -m venv .venv
-
on MacOS and Linux
source .venv/bin/activate
-
on Windows CMD
.venv\Scripts\activate.bat
-
on Windows Powershell (you may need to adjust the ExecutionPolicy)
.\.venv\Scripts\Activate.ps1
To install all necessary dependencies for this project, navigate to the project's root directory in your terminal and execute
pip install -r requirements.txt
Executing this command will initiate Specmatic and execute the tests on the Flask application.
pytest test -v -s