This is an API testing project using pytest. The project tests the DummyJSON API and demonstrates automated API testing including login, data retrieval, and payload manipulation.
- Login with username and password
- Retrieve user information (
/auth/me) - Fetch lists of users, products, or other DummyJSON endpoints
- Send custom POST/GET requests and handle payloads
git clone https://github.com/jeffrey2233/test_api.git
cd test_apipython -m venv .venvWindows:
.venv\Scripts\activateLinux/macOS:
source .venv/bin/activatepip install -r requirements.txtpytestThis will automatically discover and run all tests in the tests/ directory.
Generate Allure reports to visualize test results:
pytest --alluredir=allure-results
allure serve allure-resultstest_api/
├─ .venv/ # Python virtual environment
├─ src/ # Source code (API client, helpers)
├─ tests/ # Pytest test cases
├─ requirements.txt # Project dependencies
├─ settings.ini # API credentials and base URL
└─ README.md # Project documentation
- API credentials (username, password, base URL) are stored in
settings.inior.env. - Use the
APIClientclass insrc/api_client.pyto handle login and API requests. - Tests are designed to be flexible and reusable with different DummyJSON accounts.
- Run a single test function:
pytest tests/test_auth.py::test_login- For debugging in VSCode, configure
launch.jsonwithshowReturnValue: true.